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 java 操作 elasticsearch 8.1 实现 索引的重建
  • ¥15 数据可视化Python
  • ¥15 要给毕业设计添加扫码登录的功能!!有偿
  • ¥15 kafka 分区副本增加会导致消息丢失或者不可用吗?
  • ¥15 微信公众号自制会员卡没有收款渠道啊
  • ¥15 stable diffusion
  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘