为什么我的图片不能在html电子邮件中显示?

时间:2015-12-07 00:33:02

标签: php email

我有一个发送HTML电子邮件的脚本,可以正常处理文本和HTML标签,但我无法弄清楚为什么我的图片不会显示。

function sendHtmlEmail($email, $content, $message_content){
    $to = "$email";
    $subject = "AeroBLOG - $content";

    $message = "
    <HTML>
    <HEAD>
        <TITLE>$subject</TITLE>
        <META http-equiv='content-type' content='text/html; charset=utf-8' />
        <STYLE>
    </HEAD>
    <BODY>
           $message_content
    </BODY>
    </HTML>
    ";

    $headers  = "MIME-Version: 1.0\r\n";
    $headers .= "Content-type: text/html; charset: utf8\r\n";
    $headers .= 'From: <do-not-reply@aeroblog.tk>' . "\r\n";

    if(mail($to,$subject,$message,$headers)){return true;}else{return false;}
}

致电功能:

$message="<A href=\"http://aeroblog.tk/\"><IMG src=\"http://aeroblog.tk/img/VerificationEmail.png\" alt=\"copy & paste this link into your browsers navigation bar: http://.........\" width=\"1024px\" height=\"768px\"></A>";

sendHtmlMail("myemail@example.com","Subject",$message);

以下是包含标题的完整电子邮件:

Delivered-To: oneal.michaels@gmail.com
Received: by 10.182.154.35 with SMTP id vl3csp1831038obb;
        Sun, 6 Dec 2015 16:26:01 -0800 (PST)
X-Received: by 10.13.213.14 with SMTP id x14mr19939281ywd.229.1449447961510;
        Sun, 06 Dec 2015 16:26:01 -0800 (PST)
Return-Path: <a6602671@srv10.000webhost.com>
Received: from postlady.000webhost.com (smtp5.000webhost.com. [31.170.163.248])
        by mx.google.com with ESMTP id j63si14327386ywf.69.2015.12.06.16.26.01
        for <oneal.michaels@gmail.com>;
        Sun, 06 Dec 2015 16:26:01 -0800 (PST)
Received-SPF: pass (google.com: domain of a6602671@srv10.000webhost.com designates 31.170.163.248 as permitted sender) client-ip=31.170.163.248;
Authentication-Results: mx.google.com;
       spf=pass (google.com: domain of a6602671@srv10.000webhost.com designates 31.170.163.248 as permitted sender) smtp.mailfrom=a6602671@srv10.000webhost.com
Received: by postlady.000webhost.com ([000webhost.com Mail Server], from userid 99)
    id 59C5B602FC; Mon,  7 Dec 2015 00:26:01 +0000 (UTC)
X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on
    postlady.000webhost.com
X-Spam-Level: ****
X-Spam-Status: No, score=4.6 required=7.0 tests=BODY_URI_ONLY,
    HTML_IMAGE_ONLY_08,HTML_IMAGE_RATIO_02,HTML_MESSAGE,HTML_SHORT_LINK_IMG_1,
    MIME_HTML_ONLY,TVD_RCVD_SPACE_BRACKET,T_RP_MATCHES_RCVD autolearn=disabled
    version=3.3.2
Received: from srv10.000webhost.com (srv10.000webhost.com [31.170.160.74])
    by postlady.000webhost.com ([000webhost.com Mail Server]) with ESMTP id 9924B602FB
    for <oneal.michaels@gmail.com>; Mon,  7 Dec 2015 00:25:26 +0000 (UTC)
Received: by srv10.000webhost.com (Postfix, from userid 6602671)
    id 929B018B5C7; Sun,  6 Dec 2015 19:25:26 -0500 (EST)
To: oneal.michaels@gmail.com
Subject: AeroBLOG - Verification Email: Welcome, MikeIsMyName
X-PHP-Script: aeroblog.tk/sendVerificationEmail.php for 172.73.244.114
MIME-Version: 1.0
Content-type: text/html; charset: utf8
From: <do-not-reply@aeroblog.tk>
Message-Id: <20151207002526.929B018B5C7@srv10.000webhost.com>
Date: Sun,  6 Dec 2015 19:25:26 -0500 (EST)


    <HTML>
    <HEAD>
        <TITLE>AeroBLOG - Verification Email: Welcome, MikeIsMyName</TITLE>
        <META http-equiv='content-type' content='text/html; charset=utf-8' />
        <STYLE>
    </HEAD>
    <BODY>

    <A href="http://aeroblog.tk/"><IMG src="http://aeroblog.tk/img/VerificationEmail.png" alt="copy & paste this link into your browsers navigation bar: http://........." width="1024px" height="768px"></A>

    </BODY>
    </HTML>

1 个答案:

答案 0 :(得分:0)

某些电子邮件服务器会阻止某些电子邮件中的图像内容。您是否尝试过查看&#34;源代码&#34;电子邮件?在Gmail中,您可以通过单击“显示原始消息”找到它。可能发生的另一件事是客户端无法访问您网站中的图像文件,或图像链接不正确。

如果您仍然遇到此问题,我建议您使用PHPMailer发送电子邮件。它非常易于使用,并且具有很多功能,例如SSL和TLS或电子邮件中的附件。

相关问题