troubleshooting Question

PHP mail function using IIS SMTP failing on Friendly Name

Avatar of dban00b
dban00b asked on
PHPMicrosoft IIS Web ServerEmail Protocols
2 Comments1 Solution1188 ViewsLast Modified:
I have a very simple piece of code trying to send out an email.  This works:
                  $mail_to = "test@example.com";
                  $mail_subject = "Test Subject";
                  $mail_message = "Test Message";
                  $mail_from = "admin@example.com";
                  $mail_headers = "From: ".$mail_from."";
                  mail($mail_to,$mail_subject,$mail_message,$mail_headers);

However when I try to add a friendly name to the From header like this it fails:
                  $mail_to = "test@example.com";
                  $mail_subject = "Test Subject";
                  $mail_message = "Test Message";
                  $mail_from = "admin@example.com";
                  $mail_headers = "From: Admin <".$mail_from.">";
                  mail($mail_to,$mail_subject,$mail_message,$mail_headers);

The error return by php is:

Warning: mail() [function.mail]: SMTP server response: 501 5.5.4 Invalid Address in D:\www\testmail.php on line 10

And the log in IIS's SMTP server shows:

2009-03-13 20:14:44 127.0.0.1 web01 SMTPSVC1 web01 127.0.0.1 0 HELO - +web01 250 0 30 11 0 SMTP - - - -
2009-03-13 20:14:44 127.0.0.1 web01 SMTPSVC1 web01 127.0.0.1 0 MAIL - +FROM:<Admin+<admin@example.com>> 501 0 27 71 0 SMTP - - - -
2009-03-13 20:14:44 127.0.0.1 web01 SMTPSVC1 web01 127.0.0.1 0 QUIT - web01 240 0 55 4 0 SMTP - - - -

Showing that it's (re?)wrapping the from parameter in <> which is, of course, malformed.

I have no idea which piece of the puzzle needs to be fixed or how to go about it.
ASKER CERTIFIED SOLUTION
Chris Dent
PowerShell Developer
Join our community to see this answer!
Unlock 1 Answer and 2 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 2 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros