【发布时间】:2013-12-16 18:32:25
【问题描述】:
我想知道是否可以在 Magento 上设置两个不同的 SMTP 服务器:
一份用于时事通讯,一份用于 Magento 系统电子邮件。
我看到可以在 template.php 中设置 SMTP,但这会影响所有电子邮件。那么可能有两个不同的吗?
谢谢大家!!
附:
我试图修改文件 /app/code/core/Mage/Newsletter/Model/Template.php 正如帖子中所建议的: Magento - How enable SMTP server authentication and secure transport?
并以这种方式使用代码:
public function getMail()
{
if (is_null($this->_mail)) {
/*Start of added code to specify config*/
$my_smtp_host = 'smtp.mysmtp.com'; // Take it from Magento backoffice or you can specify it here
$my_smtp_port = '587'; // Take it from Magento backoffice or you can specify it here
$config = array(
'port' => $my_smtp_port, //optional - default 25
'auth' => 'login',
'username' => 'mylogin@email.it',
'password' => 'mypassword'
);
$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;
}
不幸的是使用系统 smtp 而不是使用这个。
我还评论了这两行:
ini_set('SMTP', Mage::getStoreConfig('system/smtp/host'));
ini_set('smtp_port', Mage::getStoreConfig('system/smtp/port'));
知道为什么仍在使用系统一吗?
【问题讨论】:
-
首先,可能是因为
Mage_Newsletter_Model_Template -> getMail()不是修补的合适位置。提到的帖子做了一个错误的假设,答案忽略了它并指向使用 Ashley Shroeder 的模块。Mage_Core_Model_Email_Template -> send()和Mage_Newsletter_Model_Template -> send()是设置邮件传输和发送邮件的位置。
标签: magento smtp newsletter