0

我正在尝试使用 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';
}

有人可以指导我这是什么问题以及如何解决它?

4

1 回答 1

1

mail()有第 4 和第 5 个参数(可选)。第 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'))
{
....
}

希望它现在可以工作:)

并在搜索邮件时检查您的垃圾邮件文件夹。

于 2013-08-22T02:26:32.477 回答