PHP mail()问题是否包含URL

时间:2013-08-22 01:58:43

标签: php php-ini

我正在尝试使用PHP mail()发送简单的html电子邮件。

以下代码罚款

$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
If(mail('xyz@gmail.com', 'test mail', 'test<hr>this is a test mail', $headers)){
  Echo 'OK';
} else{
  Echo 'Not ok';
}

问题:只要我将某些特定网址放入正文中,代码仍然可以说它没问题但邮件从未收到

If(mail('xyz@gmail.com', 'test mail', 'test<hr>this is a test mail from www.xyz.com', $headers)){
  Echo 'OK';
} else{
  Echo 'Not ok';
}

有人可以指导我这个问题以及如何解决它吗?

1 个答案:

答案 0 :(得分:1)

mail()有第4个和第5个参数(可选)。第五个参数是应该作为选项直接传递给sendmail的内容。使用以下内容:

$body = 'test<hr>this is a test mail from'.htmlentities('www.xyz.com');

if(mail('xyz@gmail.com','test mail', $body,$headers,'-f from@xyz.com'))
{
....
}

希望它现在有效:)

在搜索邮件时请检查垃圾邮件文件夹。