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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Mail function's first parameter vs. header for 'To:'.

Status
Not open for further replies.

superslurpee

Programmer
May 15, 2002
108
0
0
Hi,

In sending an email using the email function, I've got the email address as both the first parameter:
Code:
mail('email@email.com',...)
and as
Code:
$headers .= "To: $email_to_name <$email_to>\n";
to get the name in there. When the email arrives, it has the address duplicated in the 'To' field such as:
Code:
To: email@email.com, Name <email@email.com>
.

I know that if I take out the first parameter in the mail function and leave the where it's going to the headers it works fine. I've read that you must have that first parameter for certain email programs. The often mentioned tutorial at sitepoint includes the address in both the first mail function parameter and in the headers:
What should I be doing here?

Thanks!
 
Have you tried putting the name into the first variable of the mail function call? mail('Their Name <email@email.com>',...)?

Use the "<" and ">" like I have them in there, it's part of the mail RFC. Try that and leave out the To: header.
 
There are several classes, well written code, that make tinkering with mail format superfluos.
There is a full mail class in PEAR, and as always, I recommend PHPMailer available a tphpmialer.sourceforge.net
 
I had the same issue you describe a while ago, while moving a page from one server to another. I was allready using a library allready btw, and it didn't cause nor solve my problem.

Seems to me it depends on the mailserver used wether a mail with both & a To & a header with To gets send to 2 addresses or only 1
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top