dongwo2772 2015-12-19 19:16
浏览 247
已采纳

使用mail()设置Sender-header

Short version of question:

How can I set the Sender: header to webmaster@ourdomain.com when mailing with mail() in PHP?

(That is the Sender: header, NOT the From: header)

Long version:

We have issues with our server sent mail being falsely identified as SPAM. Ordinary mail (from mail clients) does not have that problem (DKIM/SPF all OK).

The big difference between the normal and server sent mail is the "Sender:" header. When sending mail from a mail client all is well:

From: name@ourdomain.com
X-Sender: name@ourdomain.com

The headers on a mail sent via PHP read:

From: name@ourdomain.com
Sender: admin@vps1949.ourvpsprovider.com  

That 2nd mailaddress does exist but I absolutely don't want our admin mail address there. And the admin address makes some mail servers think it is SPAM -- which it is absolutely NOT. (It is seen as SPAM, since, even though we have an MX record and SPF record in the DNS for vps1949.ourvpsprovider.com, these are somehow not recognised by the mailservers. I am only medium experienced with DNS, not enough to understand why this happens.)

ourdomain.com and vps1949.ourvpsprovider.com of course point to the same IP.

So how can I set the Sender: header to webmaster@ourdomain.com when mailing with mail() in PHP? That would solve it for us.

(That is the Sender: header, NOT the From: header)

This would solve all our problems.

No luck on Google, I've searched for hours and tried several things to no avail. (The -f flag on sendmail is NOT a solution, for instance.)

Since we have a VPS, I have full server access, so altering or adding an ini file is possible, if needed. (I could not find a sendmail.ini.)

Anyone can help?

  • 写回答

2条回答 默认 最新

  • dongshou2024 2016-01-02 18:13
    关注

    I solved it by changing the host name on the server. I found How to change envelope from address using PHP mail? and took the answer that everybody disliked. It worked. Finally, took weeks and weeks to find this... So easy.

    For anyone who has the same and happens to be running on CentOs 7: http://www.itzgeek.com/how-tos/linux/centos-how-tos/change-hostname-in-centos-7-rhel-7.html

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

报告相同问题?

悬赏问题

  • ¥65 永磁型步进电机PID算法
  • ¥15 sqlite 附加(attach database)加密数据库时,返回26是什么原因呢?
  • ¥88 找成都本地经验丰富懂小程序开发的技术大咖
  • ¥15 如何处理复杂数据表格的除法运算
  • ¥15 如何用stc8h1k08的片子做485数据透传的功能?(关键词-串口)
  • ¥15 有兄弟姐妹会用word插图功能制作类似citespace的图片吗?
  • ¥15 latex怎么处理论文引理引用参考文献
  • ¥15 请教:如何用postman调用本地虚拟机区块链接上的合约?
  • ¥15 为什么使用javacv转封装rtsp为rtmp时出现如下问题:[h264 @ 000000004faf7500]no frame?
  • ¥15 乘性高斯噪声在深度学习网络中的应用