PHP邮件功能不工作
我有一个发送电子邮件的php脚本。看起来是这样的:PHP邮件功能不工作,php,email,Php,Email,我有一个发送电子邮件的php脚本。看起来是这样的: <?php // subject $subject = "$first_name $last_name has sent you a message on The Red-line"; // message $message = "<html> <head> <title> The Red-line </title> </hea
<?php
// subject
$subject = "$first_name $last_name has sent you a message on The Red-line";
// message
$message = "<html>
<head>
<title>
The Red-line
</title>
</head>
<body>
<p>
Hi $war_first,
</p> <br />
<p>
$first_name $last_name has sent you a message on the Red-line. To view your message, please login to <a href='www.thered-line.com'>the Red-line.</a>
</p> <br />
<p>
Sincerely,
</p> <br />
<p>
The Red-line Operator
</p>
</body>
</html>";
// To send HTML mail, the Content-type header must be set
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
// Additional headers
$headers .= "From: The Red-line messages@theredline.com \r\n";
$headers .= "To: $war_first $last_war <$war_mail>\r\n";
// Mail it
mail($war_mail, $subject, $message, $headers);
?>
当我在远程服务器上测试时,我用这个脚本向我的收件箱发送了一封电子邮件turbocapitalist1987@yahoo.com. 我收到了电子邮件,但“发件人”部分不起作用。雅虎说我的电子邮件是从the@yahoo.com"
有人知道为什么这不起作用吗
感谢您的发件人标题,请将实际地址附在
中:
$headers .= "From: The Red-line <messages@theredline.com> \r\n";
$headers.=“发件人:红线\r\n”;
这是当您同时拥有显示名称和电子邮件地址时要使用的。我猜Yahoo将第一个单词“the”解释为整个电子邮件地址,并为该域提供了一个默认地址(Yahoo.com)。对于发件人标题,请将实际地址用
括起来:
$headers .= "From: The Red-line <messages@theredline.com> \r\n";
$headers.=“发件人:红线\r\n”;
这是当您同时拥有显示名称和电子邮件地址时要使用的。我猜Yahoo将第一个单词“the”解释为整个电子邮件地址,并为该域提供了一个默认值(Yahoo.com)。似乎是您的问题,应该是:
$headers .= "From: The Red-line <messages@theredline.com> \r\n";
$headers.=“发件人:红线\r\n”;
其次,在Unix/Linux上,您必须在服务器上配置一个工作MTA(即:sendmail、postfix等),以便直接中继邮件,或通过电子邮件转发邮件。如果您在Windows上,则必须在php.ini中配置SMTP服务器。问题似乎出在您身上,应该是:
$headers .= "From: The Red-line <messages@theredline.com> \r\n";
$headers.=“发件人:红线\r\n”;
其次,在Unix/Linux上,您必须在服务器上配置一个工作MTA(即:sendmail、postfix等),以便直接中继邮件,或通过电子邮件转发邮件。如果您在Windows上,您必须在php.ini中配置SMTP服务器。我建议使用预构建的php电子邮件库,如:我建议使用预构建的php电子邮件库,如:非常感谢,伙计。总是这些小的语法错误让我想起了guard lol。非常感谢,伙计。总是这些小的语法错误让我想起了guard lol。