码迷,mamicode.com
首页 > 其他好文 > 详细

【转】Prestashop SMTP模式发送邮件客户邮件(联系我们页面)收到不的解决办法

时间:2015-04-22 23:49:36      阅读:142      评论:0      收藏:0      [点我收藏+]

标签:

Prestashop 一般默认使用 mail 函数发送邮件,邮件发送的IP地址就是服务器或者共享空间的IP地址。共享空间上面的网站很多,可能存在发送垃圾邮件的网站,导致共享空间的IP地址被其 他邮件服务商(gmail、hotmail等等)加入黑名单,使用mail发送的邮件全部不能够发送成功。

更换使用第三方邮件来发送邮件,Prestashop 后台设置的发送邮件模式更换成SMTP。

经过测试发现:使用SMTP发送邮件,当发件人为非SMTP账户邮箱时,发送邮件成功,但是收件人收不到邮件。

联系我们(contact us)页面发送邮件给网站管理者,发件人为客户的邮箱,这样的邮件都收不到。我的订单页面也存在这种问题。

如果设置发件人邮箱为SMTP账户邮箱,能够正常收到邮件。从网站后台给客户发送邮件,客户都能够收到邮件。从后台发送的邮件,发件人为SMTP账户邮箱。

Magento开发者也许考虑到这个问题,他们给出了很好的解决方案。Magento联系我们页面,客户发送的邮件,发件人就是SMTP账户邮箱,但是回复收件人邮箱是客户邮箱。

综合考虑上面的情况,只能够采用Magento的那种邮件处理模式来解决问题。发件人设置为SMTP账户邮箱,回复邮箱设置成客户邮箱。

找到Prestashop classes/Mail.php 文件,修改地方如下:

        // 102-104 行之间修改代码

        // $from_name is not that important, no need to die if it is not valid
        if (!isset($from_name) || !Validate::isMailName($from_name))
            $from_name = $configuration[‘PS_SHOP_NAME‘];
        if (!Validate::isMailName($from_name))
            $from_name = null;

        // 设置回复邮箱为客户邮箱
        $email_reply_to = $from;
        // 设置发件人邮箱为SMTP账户邮箱
        $from = $configuration[‘PS_SHOP_EMAIL‘];

        // It would be difficult to send an e-mail if the e-mail is not valid, so this time we can die if there is a problem
        if (!is_array($to) && !Validate::isEmail($to))
        {
            Tools::dieOrLog(Tools::displayError(‘Error: parameter "to" is corrupted‘), $die);
            return false;
        }
	// 256-264 行代码修改

        /* Create mail and attach differents parts */
	$message = new Swift_Message(‘[‘.Configuration::get(‘PS_SHOP_NAME‘, null, null, $id_shop).‘] ‘.$subject);

	$message->setCharset(‘utf-8‘);

        // 设置回复者邮箱为客户邮箱
        $message->setReplyTo($email_reply_to);

	/* Set Message-ID - getmypid() is blocked on some hosting */
	$message->setId(Mail::generateId());

	$message->headers->setEncoding(‘Q‘);

 上面的解决方法暂时适合于Prestashop 1.5.6.1,其他高版本是否修复这个漏洞,暂不清楚。

转载自:http://www.phpmarker.com/388.html

 

【转】Prestashop SMTP模式发送邮件客户邮件(联系我们页面)收到不的解决办法

标签:

原文地址:http://www.cnblogs.com/lyg1990/p/4448893.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!