zoukankan      html  css  js  c++  java
  • 【转】Prestashop SMTP模式发送邮件客户邮件(联系我们页面)收到不的解决办法

    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

  • 相关阅读:
    LintCode A+B问题
    LintCode 斐波纳契数列
    LintCode 删除链表中的元素
    LintCode 整数排序
    c++ lower_bound upper_bound
    259. 3Sum Smaller
    86. Partition List
    209. Minimum Size Subarray Sum
    11. Container With Most Water
    360. Sort Transformed Array
  • 原文地址:https://www.cnblogs.com/lyg1990/p/4448893.html
Copyright © 2011-2022 走看看