$subject = 'Test';
$body = '<html>
<head>
<title>Birthday Reminders for August</title>
</head>
<body>
<a href="http://lancenewman.me">Test</a>
</body>
</html>';
$headers = 'MIME-Version: 1.0' . ''r'n';
$headers .= 'Content-type: text/html; charset=iso-8859-1' . ''r'n';
$headers .= 'From: Lance <support@lancenewman.me>' . ''r'n';
$headers .= 'To: User <email@me.com>' . ''r'n';
//echo $headers;
mail('myemail@me.com', $subject, $body, $headers)or die('error');
电子邮件已发送,但to
和from
标头未正确显示。Gmail说电子邮件已发送到我的电子邮件,但不是我的名字(Lance(,因为它应该发送。from
标头也是如此。此外,所有 html 标签都显示在电子邮件中。
有什么想法吗?
我相信
这与''r'n'
在单引号而不是双引号中有关,例如"'r'n"
,因此它没有被评估,只是一个字符串文字。