当我在邮件正文中添加“a href tag”时,邮件不会发送。
如果我删除此“a href 和 www”标签,邮件将按照我的要求发送并显示所有其他内容。
我不知 Prop 体问题出在哪里,我使用的是 PHP 5.3 版本的 GoDaddy 托管。
如果有人有更好的解决方案请与我分享。
<?php
// multiple recipients
$to = 'ali.dzinemedia@gmail.com';
// subject
$subject = 'Birthday Reminders for August';
// message
$message = '<a href=www.google.com>Click here</a>';
// To send HTML `enter code here`mail, the Content-type header must be set
$headers = 'MIME-Version: 1.0' . "\r\n";
// Additional headers
$headers .= 'To: Mary <ali.dzinemedia@gmail.com>' . "\r\n";
$headers .= 'From: Birthday Reminder <ali.dzinemedia@gmail.com>' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'X-Mailer: PHP/' . phpversion();
echo "To : ".$to;
// Mail it
mail($to, $subject, $message, $headers);
最佳答案
使用它作为标题:
$header = "MIME-Version: 1.0\r\n";
$header .= "Content-type: text/html; charset: utf8\r\n";
如果您想在正文中使用 HTML,但您必须创建格式良好的 HTML,您知道它的所有标签:html、head、body,并将它们全部关闭。
<html>
<head></head>
<body>Content here and <a href="#">this</a> is a link</body>
</html>
关于当正文中有 url a 标签时 PHP 邮件无法发送,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18780657/