简体   繁体   中英

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@gmail.com',
           '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 ?

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' => 'youremail@gmail.com',
              '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

You shouldn't be make change to core.

Instead create a custom module, take a look @ Use any SMTP to send mail in Magento

Take a look at Send email in magento using your GMail or Google Apps account

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM