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?
mail addition_headers help
Moderator: General Moderators
-
alex.barylski
- DevNet Evangelist
- Posts: 6267
- Joined: Tue Dec 21, 2004 5:00 pm
- Location: Winnipeg
Re: mail addition_headers help
Use SwiftMailer
Re: mail addition_headers help
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
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";
$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";