doushi9729 2010-09-09 10:06
浏览 43
已采纳

HTML链接向Gmail发送电子邮件时出错

Hello i have developed a newsletter script to send HTML emails.

Everything works great receiving to desktop email clients, but i notice when i send to a gmail account, the html links are not working while embedded images, css, table layout work great. Gmail change

<a href="myurl" title="My url">link</a>

to

<a title="My url">link</a>

i found a few topics around, without solutions.

this is how i build the email, in the $body var are the standard html links:

function send_mail ($from,$to,$subject,$body,$site_skin,$site_name,$site_url) { //general header $header = "From: $site_name "; $header .="BCC: $to "; $header .= "X-Mailer: PHP5.3 ";

//separator string
$boundary = "==String_Boundary_x" .md5(time()). "x";

// specific message header
$header .= "MIME-Version: 1.0
";
$header .= "Content-Type: multipart/related;
";
$header .= " boundary=\"$boundary\";

";

//this part is viewed only if the program cannot manage the MIME
$message = "your software dosen't support MIME

";
$message .= "--$boundary
";
$message .= "Content-Type: text/html; charset=\"utf-8\"
";
$message .= "Content-Transfer-Encoding: 7bit

";

$title_newsletter ="$subject";
$mail_body = $body; 
$subject = "$titoloNSL";
$mail_site_url="$site_url";

include ("../../../../themes/skins/$site_skin/email/email.php");
$message .= "$htmlBody";

$message .= "--$boundary
";
$message .= "Content-ID: <header>
";
$message .= "Content-Type: image/jpeg
";
$message .= "Content-Transfer-Encoding: base64

";

$embedded_file = "../../../../themes/skins/$site_skin/images/mail_header.jpg";
$file = fopen($embedded_file,'rb');
$data = fread($file,filesize($embedded_file));
fclose($file);

$data = chunk_split(base64_encode($data));
$message .= "$data

";

$message .= "--$boundary
";
$message .= "Content-ID: <go>
";
$message .= "Content-Type: image/gif
";
$message .= "Content-Transfer-Encoding: base64

";

$embedded_file = "../../../../themes/skins/$site_skin/images/go.gif";
$file = fopen($embedded_file,'rb');
$data = fread($file,filesize($embedded_file));
fclose($file);

$data = chunk_split(base64_encode($data));
$message .= "$data

";

$message .= "--$boundary--
";

@mail($to, $subject, $message, $header); 

}

  • 写回答

1条回答 默认 最新

  • dongmaoluan5719 2010-09-09 11:38
    关注

    My guess is that there's nothing wrong with your code; it looks like it's Gmail that's stripping the links out of your HTML at their end.

    Possibly your URLs are falling foul of their spam filters, or something like that?

    If that's case, I don't know that there's anything you can do in your PHP code to improve things (short of sending the email as plain text instead of html).

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 如何绘制动力学系统的相图
  • ¥15 对接wps接口实现获取元数据
  • ¥20 给自己本科IT专业毕业的妹m找个实习工作
  • ¥15 用友U8:向一个无法连接的网络尝试了一个套接字操作,如何解决?
  • ¥30 我的代码按理说完成了模型的搭建、训练、验证测试等工作(标签-网络|关键词-变化检测)
  • ¥50 mac mini外接显示器 画质字体模糊
  • ¥15 TLS1.2协议通信解密
  • ¥40 图书信息管理系统程序编写
  • ¥20 Qcustomplot缩小曲线形状问题
  • ¥15 企业资源规划ERP沙盘模拟