php邮件()头问题

php邮件()头问题,php,Php,这是我的密码 $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); 但是,当我打开此文件时,它会成功地将邮件发送到$to,但邮件头不正确……我的托管服务器默认地址是mars.my

这是我的密码

$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);

但是,当我打开此文件时,它会成功地将邮件发送到
$to
,但邮件头不正确……我的托管服务器默认地址是mars.myhosting.com,而不是mydomain@domain.com我如何解决这个问题?下面是我通过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);

?>


我希望这对一些人有所帮助:)

以下是我通过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);

?>


我希望这能对一些人有所帮助:)

从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);
$to='1!'nobody@example.com';
$subject='主题';
$message='hello';
$headers='From:Webmaster'。“\r\n”。
答复:webmaster@example.com' . “\r\n”。
“X-Mailer:PHP/”。phpversion();
邮件($to、$subject、$message、$headers);

添加from标题

从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);
$to='1!'nobody@example.com';
$subject='主题';
$message='hello';
$headers='From:Webmaster'。“\r\n”。
答复:webmaster@example.com' . “\r\n”。
“X-Mailer:PHP/”。phpversion();
邮件($to、$subject、$message、$headers);

添加from标头

您正在对“headers”变量使用连接运算符。变量的完整值是多少?另外,您是否在邮件服务器上启用了跟踪功能,或者使用网络嗅探器查看实际发送的内容?您正在对“headers”变量使用连接运算符。变量的完整值是多少?另外,您是否在邮件服务器上启用了跟踪功能,或者使用了网络嗅探器来查看实际发送的内容?它应该发送html标头还是不应该发送html标头