Page 1 of 1

mail addition_headers help

Posted: Tue Nov 18, 2008 7:31 pm
by dsofky
Okay, I am hoping someone can easily answer this. I've been looking for 5 hours on how to solve this and have read parts of RFC2822 and am still not having any luck. I am trying to compose an automated email sent out from our server when a new user registers on our website. I have never had a problem constructing an email until today. This is the construction of my email:

$subject = "Registration Successful";
$headers = "MIME-Version: 1.0 \r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1 \r\n";
$headers .= "From: My Company, Inc. <webmaster@somedomain.tld> \r\n";

The problem I'm having is that the comma above (,) is causing the email to default to the email address of: Web Solutions@FDQN. (where FQDN is the fully qualified domain name of my server) If I remove the comma, the email format is fine and shows as My Company Inc. <webmaster@somedomain.tld>, but when I include the comma it causes problems and only shows My Company@FQDN. The client I'm designing the site for is okay with the comma not being there, but now this has become a battle between me and this stupid comma. I have tried about 30 different ways for escaping this string, using ASCII codes instead of the actual comma, using the us-ascii charset instead of iso-8859-1 amongst many other things and this is really starting to drive me crazy. (by the way, Postfix is my MTA) Can anyone please help?

Re: mail addition_headers help

Posted: Tue Nov 18, 2008 7:43 pm
by alex.barylski
Use SwiftMailer

Re: mail addition_headers help

Posted: Tue Nov 18, 2008 7:51 pm
by dsofky
Thanks for the speedy reply PCSpectra! I will definitely check out SwiftMailer, but is there something I'm doing wrong or have I encountered a limitation of php+postfix?

Re: mail addition_headers help

Posted: Wed Nov 19, 2008 8:33 am
by dsofky
I ended up figuring out the solution to my problem was simply double quotes (") missing around the "user friendly" name I wanted others to see. This was my solution:

$subject = 'Registration Successful';
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'From: "My Company, Inc." <webmaster@somedomain.tld>' . "\r\n";