Sending mails through SMTP settings in Magento
Why SMTP is required to deliver emails rather than normal server email:
Sometimes you might see your emails are being sent to Spam folder not in Inbox . It might be its an issue of your default mail settings which are not sending proper header or that server is blacklisted to deliver emails in that case SMTP might be a good option
By Default magento sends email from server itself which includes all emails like contacts email to transactional emails. If we want to use SMTP as our outgoing server then here are the steps to configure SMTP with Magento
Step 1: Login to magento Admin
Step 2: Go to System->Configuration->Advanced->System->Mail Sending Settings.
Step 3: Insert your SMTP host name and Port No.
Step 4: Copy the file app/code/core/Mage/core/Model/Email/Template.php in your local folder so that we can override getMail() function
Override GetMail function in magento to deliver SMTP based email
Open your local folder and write and make certain changes to your getMail() . After your change your getMail() should look like
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 protected]’,
‘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 now your are done with your setup with SMTP in magento.
Note: Here its notable that only professional SMTP details (not regular like gmail or yahoo) gives good delivery rates . Because after doing these changes now SMTP is handeling all of your email related communication.
Chandra Shekhar
Latest posts by Chandra Shekhar (see all)
- Best practices for micro service design - January 23, 2022
- Spring Boot - January 23, 2022
- Java - January 23, 2022
Recent Comments