Sucessful email with IIS SMTP and Magento
When running Magento under IIS most people will want to use the built in SMTP server. Unfortunately this doesn’t work out of the box as Magento sends both the to address and a from name in the email message, which is not correctly handled in the IIS smtp service. Emails will apear to send but will never be delivered. The solution is to override the email template in the magento core with a version which does not pass the username.
to do this copy \app\code\core\Mage\Core\Model\Email\template.php to \app\code\local\Mage\Core\Model\Email\template.php
Modify the section at about line 354 from
</pre>
$mail->setSubject('=?utf-8?B?'.base64_encode($this->getProcessedTemplateSubject($variables)).'?=');
$mail->setFrom($this->getSenderEmail(), $this->getSenderName());
<pre>
to
</pre>
$mail->setSubject('=?utf-8?B?'.base64_encode($this->getProcessedTemplateSubject($variables)).'?=');
$mail->setFrom($this->getSenderEmail());
Add a file called config.xml to code/core/mage/core/etc/config.xml this must contain the following xml
<?xml version="1.0"?> <config> <modules> <Mage_Core> <version>0.0.1</version> </Mage_Core> </modules> <global> <models> <core> <class>Mage_Core_Model</class> </core> </models> </global> <span style="font-family: Georgia; line-height: 19px; white-space: normal; font-size: 13px;"> <pre style="font: normal normal normal 12px/18px 'Courier New', monospace;">
Restart PHP.
If emails still don’t work check the following
- The machine has permisisons to relay – add 127.0.01 to the list of IPs permitted to relay in the SMTP server config
- Activate logging and check that the server connects to another mail server and doesn’t recieve an error – usually a number 5xx
- The domain you are sending from has the ip address of the server included in the SPF record.