Hi,
I am having a problem with my PHP mail function. I am trying to send an email from user@site.com. This code is fine:

mail($to, $subject, $body,
    "From: user@site.com\n" .
    "MIME-Version: 1.0\n" .
    "Content-Type: multipart/alternative;\n" .
    "     boundary=" . $mime_boundary_header) or die('Mail Error');

however this does not

mail($to, $subject, $body,
    "From: Mr. User <user@site.com>\n" .
    "MIME-Version: 1.0\n" .
    "Content-Type: multipart/alternative;\n" .
    "     boundary=" . $mime_boundary_header) or die('Mail Error');

The exact error returned is

[Sat Sep 26 21:08:11 2009] [error] [client 127.0.0.1] PHP Warning:  mail() [<a href='function.mail'>function.mail</a>]: SMTP server response: 501 &lt;&lt;TubeTool&gt; user@site&gt;: missing or malformed local part in [removed for security]\\scripts\\0\\saccount\\signup.php on line 168, referer: [...]

Please note that the &lt; and &gt; are exactly that in the error log not < or >
Regards,
Sam Rudge

Perhaps this might be better:

mail($to, $subject, $body,
    "From: Mr. User <user@site.com>\r\n" .
    "MIME-Version: 1.0\r\n" .
    "Content-Type: multipart/alternative;\r\n" .
    "     boundary=" . $mime_boundary_header."\r\n") or die('Mail Error');

Perhaps this might be better:

mail($to, $subject, $body,
    "From: Mr. User <user@site.com>\r\n" .
    "MIME-Version: 1.0\r\n" .
    "Content-Type: multipart/alternative;\r\n" .
    "     boundary=" . $mime_boundary_header."\r\n") or die('Mail Error');

Thanks for the suggestion but same error again :(

mail($to, $subject, $body,
    "From: Mr. User <user@site.com>\r\n" .
    "MIME-Version: 1.0\r\n" .
    "Content-Type: multipart/mixed; boundary=\"----------A4D921C2D10D7DB\"\r\n") or die('Mail Error');
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.