SMTP settings for Magento

If you want to send emails with Magento you need to configure it to use an SMTP server – that is, the outgoing server that takes care of delivering your messages.

Remember anyway that if you set a normal SMTP server on Magento – like the ones associated to Gmail or Hotmail – you could always run into deliverability problems. Only a professional SMTP service will guarantee a full delivery rate, so if you plan to set up an email campaign you should consider this option seriously.

And here’s the procedure:

1. Login to Magento and choose System->Configuration->Advanced->System->Mail Sending Settings.

2. Insert your SMTP settings: your SMTP server name (if you don’t know it have a look at our handy list of the major ones) and your SMTP port (the default one is 25, but you can choose among others as well).

3. Copy in your local the file app/code/core/Mage/core/Model/Email/Template.php.

4. Enable that module.

5. Open the file Template.php and change the getMail() function this way:

public function getMail()
{
if (is_null($this->_mail)) {
/* changes begin */
$my_smtp_host = Mage::getStoreConfig(‘system/smtp/host’);
$my_smtp_port = Mage::getStoreConfig(‘system/smtp/port’);
$config = array(
‘port’ => $my_smtp_port,                                              ‘auth’ => ‘login’,
‘username’ => ’email@domain.com’,
‘password’ => ‘yourpassword’                                               );
$transport = new Zend_Mail_Transport_Smtp($my_smtp_host, $config);
Zend_Mail::setDefaultTransport($transport);
/* Changes End */
$this->_mail = new Zend_Mail(‘utf-8’);
}
return $this->_mail;  
}

That’s it, you can deliver emails with Magento.