Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Magento - How enable SMTP server authentication and secure transport?

I'd like to make the SMTP server working on Magento app(version 1.7). so I added the following code on file app/code/core/Mage/Core/Model/Email/Template.php

public function getMail()
    {
        if (is_null($this->_mail)) {

            /*Start of added code to specify config*/
            $my_smtp_host = Mage::getStoreConfig('system/smtp/host');
            $my_smtp_port = Mage::getStoreConfig('system/smtp/port'); 

            $config = array(
                    'ssl' => 'tls',
                    'port' => $my_smtp_port,
                    'auth' => 'login',
                    'username' => '[email protected]',
                    'password' => 'secret'
            );

            $transport = new Zend_Mail_Transport_Smtp($my_smtp_host, $config);

            Zend_Mail::setDefaultTransport($transport);
            /*End of added code to specify config*/

            $this->_mail = new Zend_Mail('utf-8');
        }
        return $this->_mail;
    }

Then on Admin Panel->System->Configuration->Advanced->System->Mail sending settings

The following settings have been added

  • Host: smtp.gmail.com
  • Port(25): 587

After completing these changes, I did test (i.e. Email to a Friend )on frontend. The success message was shown but the email wasn't in the mailbox(Not even in the spam).

Hope anyone can help me. Really appreciate,Thanks!

like image 733
DHC Avatar asked Dec 09 '22 22:12

DHC


1 Answers

You should not hack into the core code, there are many reasons because this it NOT a good idea. One is: You aren't able to upgrade.

Instead use a extension or write your own: http://www.magentocommerce.com/magento-connect/ASchroder/extension/1865/aschroder.com-smtp-pro

like image 57
Fabian Blechschmidt Avatar answered Dec 26 '22 17:12

Fabian Blechschmidt