Magento: mini_sendmail and Zend_Mail incompatibility

This article is now deprecated and the issue has been resolved without changes to core code after our service change.

We have recently spotted an issue after traversing our Apache sendmail application to mini_sendmail (read more about the change).

In Magento’s mail headers, the recipient and sender details have both the email address and respective name, however, this breaks compatibility with mini_sendmail.

As mini_sendmail does not support anything other than just the email address alone for the recipient/sender, emails from Magento will fail to send.

As a temporary measure a fix can be issued in the form of editing core code.

1) Enter the root directory of your Magento store and enter

# mkdir app/code/local/Mage
# mkdir app/code/local/Mage/Core
# mkdir app/code/local/Mage/Core/Model
# mkdir app/code/local/Mage/Core/Model/Email
# cp app/code/core/Mage/Core/Model/Email/Template.php  app/code/local/Mage/Core/Model/Email/

2) Using your favourite editor open up Template.php and make changes at these lines

        ini_set('SMTP', Mage::getStoreConfig('system/smtp/host'));
        ini_set('smtp_port', Mage::getStoreConfig('system/smtp/port'));
        $mail = $this->getMail();
        if (is_array($email)) {
            foreach ($email as $emailOne) {
+               # Fix for mini_sendmail
+                # $mail->addTo($emailOne, $name);
+                $mail->addTo($emailOne);
-                $mail->addTo($emailOne, $name);
            }
        } else {
+           # Fix for mini_sendmail
+           # $mail->addTo($email, '=?utf-8?B?'.base64_encode($name).'?=');
+           $mail->addTo($email);
-           $mail->addTo($email, '=?utf-8?B?'.base64_encode($name).'?=');
        }
        $this->setUseAbsoluteLinks(true);
        $text = $this->getProcessedTemplate($variables, true);
        $mail->setSubject('=?utf-8?B?'.base64_encode($this->getProcessedTemplateSubject($variables)).'?=');
+       # Fix for mini_sendmail
+       # $mail->setFrom($this->getSenderEmail(), $this->getSenderName());
+       mail->setFrom($this->getSenderEmail());
-       $mail->setFrom($this->getSenderEmail(), $this->getSenderName());

3) Recompile (if using extension) to update includes

It is not a perfect solution, but should provide a fix until we find an alternative to mini_sendmail.

This entry was posted in Knowledge Base, Magento and tagged , , , , , . Bookmark the permalink.

One Response to Magento: mini_sendmail and Zend_Mail incompatibility

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">