PHP Mail() fails with "User <[email protected]>", fine with "<[email protected]>"

267 views Asked by At

Problem began with Magento not sending mails, and while debugging I came to this:

when using PHP mail function, it fails if $to contains Name.

<?php
 $to = '<[email protected]>'; //Works fine
 $to = '[email protected]'; //Works fine

 $to = 'Myname <[email protected]>'; // This doesn't work! No mail and getting "delivery failed";

 $subject = "Test";
 $body = "How are you?";

 if (mail($to, $subject, $body)) {
   echo("Message successfully sent!");
 } else {
  echo("Message delivery failed...");
 }
?>

This is a hosted account, so I don't have access to sendmail or any other configs.

1

There are 1 answers

0
Pavel On

Haven't found solutions to this specific problem, but found Magento plugin, which uses SMTP/Google Mail/Apps . Working fine, sending mails.

http://www.magentocommerce.com/magento-connect/aschroder-com-smtp-pro-email-free-and-easy-magento-emailing-for-smtp-gmail-or-google-apps-email.html