这是我的代码......
$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怎么能我解决了这个问题
答案 0 :(得分:3)
从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);
添加标题
答案 1 :(得分:2)
以下是我将通过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);
?>
我希望有所帮助:)