php电子邮件标题 [英] php email headers

查看:122
本文介绍了php电子邮件标题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在以下脚本中更改'from'电子邮件标题时遇到问题。其他的一切都可以正常工作,但是收到的电子邮件地址是服务器名称,而不是admin@mywebsite.com:

I am having problems changing the 'from' email header in the following script. Everthing else works ok but the from line in the email received is the server name and not admin@mywebsite.com:

ini_set("sendmail_from", " admin@mywebsite.com ");

    $adminSendTo = "admin@mywebsite.com";

    $adminSubject = "Contact Form";
    $adminMessage = "Contact Form: $subfirstname $sublastname \r\rEmail: $subemail \r\rSubject of feedback: $subsubject \r\rComments: $subcommentquestion\r\n";
    $adminHeaders = "From: My website Contact Form\r\n";
    $adminHeaders = "Reply-To: admin@mywebsite.com";

    mail($adminSendTo, $adminSubject, $adminMessage, $adminHeaders);

我需要更改php.ini文件中的设置才能工作吗?

Do I need to change settings in the php.ini file for this to work?

推荐答案

实际上,您不提供任何From字段。

Actually, you don't provide any "From" field.

通过写:

$adminHeaders = "From: My website Contact Form\r\n";
$adminHeaders = "Reply-To: admin@mywebsite.com";

您将From ...值分配给 $ adminHeaders ,然后通过新值覆盖下一行回复...

you assign the "From..." value to $adminHeaders, then overwrite just on the next line by a new value "Reply-To...".

相反,你应该写:

$adminHeaders = "From: My website Contact Form\r\n";
$adminHeaders .= "Reply-To: admin@mywebsite.com";

这里,回复...将连接到实际价值 $ adminHeaders ,而不是覆盖它。

Here, "Reply-To..." will be concatenated to the actual value of $adminHeaders, instead of overwriting it.

这篇关于php电子邮件标题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆