我正在使用代码通过php发送邮件
$to = $_POST['userId'];
$subject = "New password received";
$body = 'Your new password is '.'"'.$newPass.'"';
if (mail($to, $subject, $body)) {
mail. Please check your mail!</p>");
$succ = 'Password successfully sent to your mail. Please check your mail!';
} else {
$err = 'Password delivery failed!';
}
现在邮件将发送给用户。但是从地址开始,他们在主机(godaddy.com)中配置。现在如何更改主机(godaddy)中的表单地址,以便我可以从收到的邮件中获取地址的欲望?
感谢..
答案 0 :(得分:2)
如果我理解正确,您想要更改此邮件的发送地址吗?如果是,请在此处查看邮件文档:http://php.net/manual/en/function.mail.php。您必须在邮件功能中添加第4个参数。这会传递邮件的标题。
$headers = 'From: webmaster@example.com' . "\r\n" .
'Reply-To: webmaster@example.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
$subject = "New password received";
$body = 'Your new password is '.'"'.$newPass.'"';
if (mail($_POST['userId'], $subject, $body, $headers)) {
$succ = 'Password successfully sent to your mail. Please check your mail!';
} else {
$err = 'Password delivery failed!';
}
答案 1 :(得分:0)
添加此
$headers = "From: kdaniel@aosepc.com\n";
if (mail($to, $subject, $body,$headers)) {