简体   繁体   English

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

[英]SPF issue when sending automatic email with php

I am having a SPF issue sending automatic email to users that register to my website. 我遇到SPF问题,向注册到我的网站的用户发送自动电子邮件。

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. 当查看gmail中的“原始”电子邮件时,我收到了以下消息,其中包含我的Cpanel和主机名详细信息,而不是我从中发送电子邮件和网站名称的电子邮件。 When sending manual emails using webmail it is working just fine. 使用网络邮件发送手动电子邮件时,它工作正常。

Here is what I get from Gmail 这是我从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 要发送电子邮件,我正在使用php邮件功能

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

Any idea about what am I missing? 我想念什么吗? Cheers 干杯

Try to use 5th argument of mail function 尝试使用mail功能的第5个参数

mail(to, subject, message, headers, "-fyour@email.com");  

otherwise sendmail uses account information in return-path field. 否则, sendmailreturn-path字段中使用帐户信息。

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()如下所示:

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

where $returnAddress is the same as your From: address. 其中$ returnAddress与您的“ From:地址相同。

It's not guaranteed as some systems flag the fact that you've used the -f parameter as a spam indicator. 由于某些系统会标记您已将-f参数用作垃圾邮件指示符,因此无法保证。

In any case, you're far better making life easier by using PHPMailer to do the job 无论如何,通过使用PHPMailer来使工作变得更轻松,更好

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM