您好我已经开发了一个通讯脚本来发送HTML电子邮件。
一切都很好地接收到桌面电子邮件客户端,但我注意到当我发送到gmail帐户时,html链接不起作用,而嵌入式图像,CSS,表格布局工作得很好。 Gmail更改
<a href="myurl" title="My url">link</a>
到
<a title="My url">link</a>
我发现了一些主题,没有解决方案。
这是我构建电子邮件的方式,在$ body var中是标准的html链接:
function send_mail($ from,$ to,$ subject,$ body,$ site_skin,$ site_name,$ site_url) { //一般标题 $ header =“From:$ site_name \ n”; $ header。=“BCC:$ to \ n”; $ header。=“X-Mailer:PHP5.3 \ n”;
//separator string
$boundary = "==String_Boundary_x" .md5(time()). "x";
// specific message header
$header .= "MIME-Version: 1.0\n";
$header .= "Content-Type: multipart/related;\n";
$header .= " boundary=\"$boundary\";\n\n";
//this part is viewed only if the program cannot manage the MIME
$message = "your software dosen't support MIME\n\n";
$message .= "--$boundary\n";
$message .= "Content-Type: text/html; charset=\"utf-8\"\n";
$message .= "Content-Transfer-Encoding: 7bit\n\n";
$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\n";
$message .= "Content-ID: <header>\n";
$message .= "Content-Type: image/jpeg\n";
$message .= "Content-Transfer-Encoding: base64\n\n";
$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\n\n";
$message .= "--$boundary\n";
$message .= "Content-ID: <go>\n";
$message .= "Content-Type: image/gif\n";
$message .= "Content-Transfer-Encoding: base64\n\n";
$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\n\n";
$message .= "--$boundary--\n";
@mail($to, $subject, $message, $header);
}
答案 0 :(得分:1)
我的猜测是你的代码没有问题;看起来它的Gmail正在剥离你的HTML链接。
您的网址可能会违反其垃圾邮件过滤器,或类似内容?
如果是这种情况,我不知道你可以在你的PHP代码中做些什么来改进(没有用纯文本而不是html发送电子邮件)。