当收到电子邮件时,mail.php不显示收件人、发件人或主题
我有下面的代码,它在一定程度上起作用。邮件已收到,但邮件顶部缺少“收件人”、“发件人”和“主题”字段。然而,它们确实出现在体内 有什么想法吗当收到电子邮件时,mail.php不显示收件人、发件人或主题,php,html,email,Php,Html,Email,我有下面的代码,它在一定程度上起作用。邮件已收到,但邮件顶部缺少“收件人”、“发件人”和“主题”字段。然而,它们确实出现在体内 有什么想法吗 require_once "Mail.php"; $from = 'noreply@example.co.uk'; $to = 'recipient@example.co.uk'; $subject = 'registration'; $body = "<html> <head> <title>......</t
require_once "Mail.php";
$from = 'noreply@example.co.uk';
$to = 'recipient@example.co.uk';
$subject = 'registration';
$body = "<html>
<head>
<title>......</title>
</head>
Body text
</html>";
$headers = array('MIME-Version' => "1.0",
'Content-type' => "text/html; charset=iso-8859-1\r\n\r\n",
'From' => $from,
'To' => $to,
'Subject' => $subject
);
$smtp = Mail::factory('smtp', array('host' => 'mail.example.co.uk',
'port' => '25',
'auth' => true,
'username' => 'noreply@example.co.uk',
'password' => 'xxxxxx'
));
$mail = $smtp->send($to, $headers, $body);
if (PEAR::isError($mail))
{
echo('<p>' . $mail->getMessage() . '</p>');
}
else
{
echo "Success";
}
require_once“Mail.php”;
$fromnoreply@example.co.uk';
$to$recipient@example.co.uk';
$subject='注册';
$body=”
......
正文
";
$headers=array('MIME-Version'=>“1.0”,
“内容类型”=>“文本/html;字符集=iso-8859-1\r\n\r\n”,
'From'=>$From,
'至'=>$至,
“主题”=>$Subject
);
$smtp=Mail::工厂('smtp',数组('host'=>'Mail.example.co.uk',
“端口”=>“25”,
“auth”=>正确,
'用户名'=>'noreply@example.co.uk',
'密码'=>'xxxxxx'
));
$mail=$smtp->send($to、$headers、$body);
if(PEAR::isError($mail))
{
echo(“”.$mail->getMessage()。”);
}
其他的
{
呼应“成功”;
}
更新
如果删除“MIME版本”=>“1.0”、“内容类型”=>“text/html;charset=iso-8859-1\r\n\r\n”行,我会看到应该看到的详细信息,但显然会丢失html格式
查看收到的电子邮件的来源:
From: noreply@example.co.uk
To: recipient@exmaple.co.uk
Subject: registration
<html>
....
</html>
来自:noreply@example.co.uk
致:recipient@exmaple.co.uk
主题:注册
....
您可以在收到邮件时发布源代码吗?请参阅编辑。。。这就是您的意思吗?您是否尝试将mime和内容类型片段移动到数组的末尾?有时候php对顺序很挑剔。太棒了-太简单了!!如果你发帖子作为回答,我会接受