[英]Php mail function unable to send HTML
I am trying to send an email with a link, the problem im facing is that outlook does not reconize the HTML which is being put in the email. 我正在尝试发送带有链接的电子邮件,面临的问题是Outlook无法协调电子邮件中所放置的HTML。
$onderwerp = "test";
$bericht = <<<EOT
<html>
<head>
<title>Email_test</title>
</head>
<body>
<a href="http://www.link.com/index.php?page=members&id={$last_insert_id}">* the link</a>
</body>
</html>
EOT;
$headers = 'From: ' . $verstuurd_van;
mail($naar_1, $onderwerp, $bericht, $headers);
Thanks in forehand for the help. 正手感谢您的帮助。
In order to be able to send a HTML email you need to add a few more headers: 为了能够发送HTML电子邮件,您需要添加一些标题:
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
So the entire email becomes something like: 因此,整个电子邮件变为:
$to = 'example@example.com';
$subject = 'Test';
$message = "
<html>
<body>
<p>
Hallo <b>Example</b>,
</p>
</body>
</html>";
$headers = "From: example@example.nl\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
mail($to, $subject, $message, $headers);
Also take a look at: https://css-tricks.com/sending-nice-html-email-with-php/ 还可以看看: https : //css-tricks.com/sending-nice-html-email-with-php/
just mention the headers in your email script like . 只需在电子邮件脚本中提及标头即可。
// Always set content-type when sending HTML email
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
so your script will 所以你的脚本会
$onderwerp = "test";
$bericht = <<<EOT
<html>
<head>
<title>Email_test</title>
</head>
<body>
<a href="http://www.link.com/index.php?page=members&id={$last_insert_id}">* the link</a>
</body>
</html>
EOT;
$headers = 'From: ' . $verstuurd_van;
$headers .= "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
mail($naar_1, $onderwerp, $bericht, $headers);
you can take reference from html email with php or w3school email html 您可以从带有php的html电子邮件或w3school电子邮件html获取参考
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.