邮件()从地址发送

如何更改PHP邮件()函数的默认地址。 我知道我可以在每次发送的基础上做,但是我想改变默认设置。

你可以用“sendmail_from”在php.ini中设置。

从php.ini:

; For Win32 only. ; http://php.net/sendmail-from ;sendmail_from = [email protected] ; For Unix only. You may supply arguments as well (default: "sendmail -t -i"). ; http://php.net/sendmail-path sendmail_path = /usr/sbin/sendmail -t 

如果由于某种原因您无法访问php.ini,则可以在.htaccess文件中设置以下内容:

 php_value sendmail_from [email protected] 

注意:出于安全原因,您不能以这种方式设置sendmail_path。 资料来源: http : //nl.php.net/manual/en/mail.configuration.php

我已经在MTA(smtp服务器)中为我们的网站pipe理员完成了这项工作。 如果您的MTA是后缀,则可以使用sender_canonical_maps查找表。 从男人5 postconf:


sender_canonical_maps(默认值:空)
信封和标题发件人的可选地址映射查找表
地址。 表格格式和查找logging在canoni-
CAL(5)。

  Example: you want to rewrite the SENDER address "[email protected]" to "[email protected]", while still being able to send mail to the RECIP‐ IENT address "[email protected]". Note: $sender_canonical_maps is processed before $canonical_maps. Example: sender_canonical_maps = hash:/etc/postfix/sender_canonical 

你需要定义一个标题,你把“From:Toto toto <[email protected]>”(没有空格,但是接口删除<>的内容)。

要在默认设置下进行更改,您不应该在PHP中执行此操作,而应在MTA中执行此操作。 把你的地址改写成你想要的。