PHP Mail() 失败并显示“用户<user@example.com>”,而“<user@example.com>”


PHP Mail() fails with "User <user@example.com>", fine with "<user@example.com>"

问题始于Magento不发送邮件,在调试时我得出了这个:

使用 PHP 邮件功能时,如果$to包含 Name,则会失败。

<?php
 $to = '<myname@gmail.com>'; //Works fine
 $to = 'myname@gmail.com'; //Works fine
 $to = 'Myname <myname@gmail.com>'; // 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...");
 }
?>

这是一个托管帐户,所以我无权访问 sendmail 或任何其他配置。

还没有找到这个特定问题的解决方案,但找到了使用 SMTP/Google Mail/Apps 的 Magento 插件。工作正常,发送邮件。

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