Search code examples
magentoemailsslsmtpgmail

Magento configuring email on Gmail


I have configured app/code/core/Mage/Core/Model/Email/Template.php:

$config = array(
           'ssl' => 'tls', 
           'port' => Mage::getStoreConfig('system/smtp/port'), // it is set to 25
           'auth' => 'login', 
           'username' => '[email protected]',
           'name' => Mage::getStoreConfig('system/smtp/host'), // it is set to smtp.gmail.com
           'password' => 'password'
       );

but im still getting exception :

Unable to send mail. mail(): SMTP server response: 530 5.7.0 Must issue a STARTTLS command first

where else I need to make changes to make it work? It is somewhere else than app/code/core/Mage/Core/Model/Email/Template.php ?


Solution

  • Described config is functional, for viewing changes in scripts is needed to turn off Magento compiler an clean /includes/folder.

    There is changed email function supporting Google Gmail or Google Apps:

    1 copy file "app/code/core/Mage/Core/Model/Email/Template.php" to "app/code/local/Mage/Core/Model/Email/Template.php"

    2 In file app/code/local/Mage/Core/Model/Email/Template.php change function:

    public function getMail()
    {
        if (is_null($this->_mail)) {
        $my_smtp_host = Mage::getStoreConfig('system/smtp/host');
        $my_smtp_port = Mage::getStoreConfig('system/smtp/port');
        $config = array(
                  'port' => $my_smtp_port,
                  'auth' => 'login',
                  'ssl' => 'tls',
                  'username' => '[email protected]',
                  'password' => 'Abc'
                  );
         $transport = new Zend_Mail_Transport_Smtp($my_smtp_host,$config);
         Zend_Mail::setDefaultTransport($transport);         
    
    
    
    
    
            $this->_mail = new Zend_Mail('utf-8');
        }
        return $this->_mail;
    }
    

    Disable compiler, rename folder /includes/ in magento root and clear cache