本文介绍了Magento - 如何启用 SMTP 服务器身份验证和安全传输?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想让 SMTP 服务器在 Magento 应用程序(1.7 版)上运行.所以我在文件 app/code/core/Mage/Core/Model/Email/Template.php

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;
    }

然后在管理面板->系统->配置->高级->系统->邮件发送设置

已添加以下设置

  • 主机:smtp.gmail.com
  • 端口(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!

推荐答案

你不应该侵入核心代码,原因有很多,因为这不是一个好主意.一种是:您无法升级.

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.

改为使用扩展程序或编写自己的扩展程序:http://www.magentocommerce.com/magento-connect/ASchroder/extension/1865/aschroder.com-smtp-pro

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

这篇关于Magento - 如何启用 SMTP 服务器身份验证和安全传输?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-23 21:52