dongmu9253 2012-03-04 06:35
浏览 51

当正文中有URL时,PHP邮件将不会发送[关闭]

I'm trying to send this html email and for some reason it won't send when there's a link in the body. The only difference between these two files seems to be that one has a link in the body. If I put the same thing in the subject it sends fine.

Works perfectly:

//mail body and subject
$mail_body = "Test Email with no link.";
$subject = "Test email with no link";

//recipient
$recipient = "myemail@mydomain.com";

//headers to send HTML email
$header = "MIME-Version: 1.0
" ;
$header = $header . "Content-Type: text/html; charset="\iso-8859-1\"
";
$header = $header . 'From: admin@test.com';

//send the message
mail($recipient, $subject, $mail_body, $header) or die('mail could not be sent'); //mail command :)
echo('Good Test');

Does Not work:

//mail body and subject
$mail_body = "Test Email with link. <a href=\"http://www.google.com\">google</a>";
$subject = "Test email with with link. ";

//recipient
$recipient = "myemail@mydomain.com";

//headers to send HTML email
$header = "MIME-Version: 1.0
" ;
$header = $header . "Content-Type: text/html; charset=\"iso-8859-1\"
";
$header = $header . 'From: admin@test.com';

//send the message
mail($recipient, $subject, $mail_body, $header) or die('mail could not be sent'); //mail command :)
echo('Bad Test');
  • 写回答

3条回答 默认 最新

  • dongtao4319 2012-03-04 06:37
    关注

    You need to escape the quotes in your e-mail address. Check the backslashes:

    $mail_body = "Test Email with link. <a href=\"http://www.google.com\">google</a>";
    
    评论

报告相同问题?

悬赏问题

  • ¥15 单片机学习顺序问题!!
  • ¥15 ikuai客户端多拨vpn,重启总是有个别重拨不上
  • ¥20 关于#anlogic#sdram#的问题,如何解决?(关键词-performance)
  • ¥15 相敏解调 matlab
  • ¥15 求lingo代码和思路
  • ¥15 公交车和无人机协同运输
  • ¥15 stm32代码移植没反应
  • ¥15 matlab基于pde算法图像修复,为什么只能对示例图像有效
  • ¥100 连续两帧图像高速减法
  • ¥15 如何绘制动力学系统的相图