[英]php mail() headers problem
here is my code.... 这是我的代码。
$subject = "This is Subject";
$headers .= 'Content-type: text/html; charset=iso-8859-1';
$to = 'foo@foo.com';
$body = 'Mail Content Here';
mail($to, $subject, $body, $headers);
but when i open this file it sends a mail to $to
successfully but with wrong headers....and my hosting server default address ie mars.myhosting.com, instead of mydomain@domain.com how can i fix that 但是,当我打开此文件时,它
$to
成功将邮件发送到$to
但是标题错误....以及我的托管服务器的默认地址,即mars.myhosting.com,而不是mydomain@domain.com,我该如何解决
Look at this from php.net 从php.net看一下
$to = 'nobody@example.com';
$subject = 'the subject';
$message = 'hello';
$headers = 'From: Webmaster <webmaster@example.com>' . "\r\n" .
'Reply-To: webmaster@example.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($to, $subject, $message, $headers);
Add the from header 添加from头
Here is what I would do via PHP: 这是我将通过PHP执行的操作:
<?PHP
$to = 'email@address.com';
$subject = 'desired subject';
$message = 'desired message';
$headers = 'From: example@email.com' . "\r\n" .
'Reply-To: example@email.com' . "\r\n" .
'Return-Path: example@email.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($to, $subject, $message, $headers);
?>
I hope that helps some :) 我希望对您有所帮助:)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.