dongyue9864 2014-11-29 04:00
浏览 226
已采纳

使用php发送自动电子邮件时的SPF问题

I am having a SPF issue sending automatic email to users that register to my website.

When looking at the "original" email in gmail I got the following message with my Cpanel and hostname details instead of the email I sent the email from and my website name. When sending manual emails using webmail it is working just fine.

Here is what I get from Gmail

Delivered-To: me@gmail.com

Received: by 10.76.116.7 with SMTP id js7csp261337oab;
        Fri, 28 Nov 2014 18:37:45 -0800 (PST)

X-Received: by 10.70.133.41 with SMTP id oz9mr78655916pdb.46.1417228665423;
        Fri, 28 Nov 2014 18:37:45 -0800 (PST)

Return-Path: <cpanel_login@hostname>

Received: from hostname (hostname [ip address*)
        by mx.google.com with ESMTPS id gb9si5051542pac.60.2014.11.28.18.37.44
        for <me@gmail.com>
        (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
        Fri, 28 Nov 2014 18:37:45 -0800 (PST)

Received-SPF: none (google.com: cpanel_logim@hostname does not designate permitted sender hosts) client-ip=ip address;

Authentication-Results: mx.google.com;
       spf=none (google.com: cpanel_login@hostname does not designate permitted sender hosts) smtp.mail=cpanel_login@hostname

Received: from cpanel_login by hostname with local (Exim 4.82)
    (envelope-from <cpanel_login@hostname>)
    id 1XuXun-00065P-Hb
    for me@gmail.com; Fri, 28 Nov 2014 18:37:44 -0800

To: me@gmail.com

Subject: Activate your account

X-PHP-Script: www.mywebsite.com/email.php for 110.174.16.98

From: "Mywebsite" <noreply@mywebsite.com>

Content-Type: text/html; charset="utf-8"
Content-Transfer-Encoding: 8bitReturn-Path: <noreply@mywebsite.com>
Message-Id: <E1XuXun-00065P-Hb@hostname>
Date: Fri, 28 Nov 2014 18:37:41 -0800

To send the email I am using the php mail function

mail($useremail, $subject, $emailBody, $headers);

Any idea about what am I missing? Cheers

  • 写回答

2条回答 默认 最新

  • douyi0219 2014-11-29 04:08
    关注

    If you send email this way the host server will use the default address for your account as a return path. You can try adding a fifth parameter to mail() like this:

    mail($to, $subject, $body, $headers, '-f'.$returnAddress);
    

    where $returnAddress is the same as your From: address.

    It's not guaranteed as some systems flag the fact that you've used the -f parameter as a spam indicator.

    In any case, you're far better making life easier by using PHPMailer to do the job

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 编写vba代码实现数据录入工作
  • ¥15 做过TCL海信电视小米电视相关影视会员软件私我
  • ¥15 Mapreduce是正常的,在运行其他jar包时并没有任何问题,只是在做LogCount.jar 时出的问题。如图所示
  • ¥15 ImportError: DLL load failed while importing _iterative: 找不到指定的模块。
  • ¥15 如何通过交互分析得出某高危患者对放疗获益更多
  • ¥15 相关性分析中,p<0.05, r=0.29,怎么评价相关性呢
  • ¥15 docker部署Mongodb后输入命令报错?
  • ¥15 将下列流程图转变成python程序代码
  • ¥15 我需要全国每个城市的最新小区名字等数据。
  • ¥15 开发一个小区生态的小程序