当正文中有一个 url a 标签时,PHP 邮件无法发送


PHP mail can not send when there is a url a tag in the body

当我在邮件正文中添加"href标签"时,邮件没有发送。

如果我删除此"href 和 www"标签,则邮件发送和所有其他内容将根据我的要求显示。

我不知道确切的问题在哪里,我正在使用 GoDaddy 托管与 PHP 5.3 版本。

如果有人有更好的解决方案,请与我分享。

<?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,头部,身体,并关闭它们。

<html>
    <head></head>
    <body>Content here and <a href="#">this</a> is a link</body>
</html>

我曾经遇到过同样的问题,结果我的垃圾邮件过滤器在链接中包含时阻止了邮件,并在我删除链接时让它低谷。

我花了一些时间才注意到