0

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 = '<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...");
 }
?>

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

Pavel
  • 383
  • 3
  • 6
  • You could add the exact name like in the example at http://php.net/manual/en/function.mail.php, see the "Sending HTML email" example and the "// Additional headers" part. That should work. – Sk8erPeter Jun 02 '12 at 23:41
  • Yep, but I cant. This is used in context of Zend, which is in context of Magento. $result = mail( $this->recipients, $this->_mail->getSubject(), $this->body, $this->header); So in first place I receive it already formed as "Name Secondname " – Pavel Jun 02 '12 at 23:46
  • I don't really understand the reasons why: I just tested it in a Linux+Apache environment, and your sample (with `'Myname '`) works without a problem - and it should (as this form complies with RFC 2822)! I think it can be a misconfiguration (for example of `sendmail`) on your server. What kind of server are you using? – Sk8erPeter Jun 03 '12 at 16:37

1 Answers1

0

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

Pavel
  • 383
  • 3
  • 6