本文介绍了如何使用PHP邮件更改地址信封?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Linux上使用Apache与Apache,使用Sendmail。我使用PHP 功能。发送电子邮件,但信封在 MAIL FROM (example [email protected])中的 Apache_user @ localhostname 并且一些远程邮件服务器拒绝这一点,因为该域不存在(显然)。使用邮件,我可以强制更改信封 MAIL FROM



编辑:如果我在邮件()函数的第四个字段中添加标题,则会更改 From 字段在邮件正文的头部,并且不更改信封 MAIL FROM



我可以通过使用 sendmail -t -odb -oi -frealname @ realhost 生成sendmail来强制它,并将邮件内容管理到它。这是一个更好的方法吗?



有更好,更简单,更适合PHP的方式吗?



编辑:底线是我应该有RTM。感谢您的答案,第五个参数的作品一切都很好。

解决方案

mail()具有第4和第5个参数可选的)。第五个参数是直接作为选项传递给sendmail。我使用以下内容:

  mail('[email protected]','subject!','body!来自:[email protected]',' -  f [email protected]'); 


I am using PHP with Apache on Linux, with Sendmail. I use the PHP mail function. The email is sent, but the envelope has the Apache_user@localhostname in MAIL FROM (example [email protected]) and some remote mail servers reject this because the domain doesn't exist (obviously). Using mail, can I force it to change the envelope MAIL FROM?

EDIT: If I add a header in the fourth field of the mail() function, that changes the From field in the headers of the body of the message, and DOES NOT change the envelope MAIL FROM.

I can force it by spawning sendmail with sendmail -t -odb -oi -frealname@realhost and piping the email contents to it. Is this a better approach?

Is there a better, simpler, more PHP appropriate way of doing this?

EDIT: The bottom line is I should have RTM. Thanks for the answers folks, the fifth parameter works and all is well.

解决方案

mail() has a 4th and 5th parameter (optional). The 5th argument is what should be passed as options directly to sendmail. I use the following:

mail('[email protected]','subject!','body!','From: [email protected]','-f [email protected]');

这篇关于如何使用PHP邮件更改地址信封?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-31 04:14