Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CFMAIL with person's full name

Status
Not open for further replies.

philcha

Programmer
May 10, 2000
109
GB
I want to use CFMAIL to send email messages which include the full name of the sender and receiver, so that for example in Outlook the senrder's name will appear in the in-tray rather than the sender's email address. According to a few things I've read on the web, the correct format for this is
John Smith<jsmith@mysite.com>

So I coded
<cfset FullEmailAddr = Name & &quot;<&quot; & EmailAddr & &quot;>&quot;>
but Cf couldn't send it. The log entries in ColdFusion\Server\Mail\Log\Errors.Log said
501 Syntax error in address John Smith<jsmith@mysite.com
(note that these omitted the final >)
but then said
Sender = John Smith<jsmith@mysite.com>
(with the final >).

So what am I doing wrong?

PS I have no trouble using CFMAIL to send emails with addresses of the form
jsmith@mysite.com
and using the same email addresses as I did in the unsuccessful attempts, so I doubt if it's a set-up problem.
 
philcha,

This is how I do it.

Code:
<cfmail from='&quot;John Smith&quot; <JSmith@aolsucks.com>'
	to='&quot;#qUser.FirstName# #qUser.LastName#&quot; <#qUser.Email#>'
	server=&quot;smtp.server.com&quot;
	subject=&quot;Test Mail&quot;>
#form.txtEmailBody#
</cfmail>

hope that helps out,
jgroove
 
Thanks, jgroove.

I forgot to mention that I'm using CF 4.0.1. A user on another forum I tried suggested CF 4.0.1 can't handle the email address format
real name<user@domain>

After quite a lot of experimenting with various combinations of:
* enclosing / not enclosing real name in quotes
* inserting / omitting a space between real name and <user@domain>
I've reluctantly concluded that CF 4.01 can't handle this format and I'll have to use plain user@domain

Thanks for trying!
 
Sorry to hear that CF 4.0.1 can't handle it. The correct format does indeed require double qoutes around the person's name and a space between the qouted name and the address enclosed within angle brackets. I noticed that none of the solutions incorporated your need to put the whole email address string into a variable before using it in CFMAIL. If you were using CF 4.5 or later, you could do this:

<cfset mail_to_string = '&quot;John Smith&quot; <jsmith@mysite.com>'>

<cfmail from=&quot;#HTMLEditFormat(mail_from_string)#&quot;
to=&quot;#HTMLEditFormat(mail_to_string)#&quot;
...
</cfmaIL>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top