mail.php收到电子邮件时未显示收件人,收件人或主题

时间:2015-03-07 19:48:42

标签: php html email

我在下面的代码在某种程度上有效。邮件已收到,但电子邮件顶部缺少发件人主题字段。然而它们确实出现在体内。

enter image description here

有什么想法吗?

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";
}

更新

如果我删除&#39; MIME-Version&#39; =&GT; &#34; 1.0&#34;,&#39;内容类型&#39; =&GT; &#34; text / html的; charset = iso-8859-1 \ r \ n \ r \ n&#34;,这些行我看到了应该的细节,但我显然丢失了html格式。

在收到的电子邮件中查看来源:

From: noreply@example.co.uk
To: recipient@exmaple.co.uk
Subject: registration

<html>
....
</html>

0 个答案:

没有答案