doushui3061 2015-12-07 00:33
浏览 197

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

I have a script for sending HTML email messages which works fine for text and html tags but I cannot figure out why my images wont display.

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
";
    $headers .= "Content-type: text/html; charset: utf8
";
    $headers .= 'From: <do-not-reply@aeroblog.tk>' . "
";

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

call to function:

$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);

Here is the complete email which is returned including headers:

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条回答 默认 最新

  • doujiao1949 2015-12-07 00:43
    关注

    Some e-mail servers blocks images contents from some e-mails. Did you try looking at the "source code" of the e-mail? In gmail you can find it by clicking in Show Original Message. Another thing that can be happening is that the client is not able to access the image file in your website, or the image link is incorrect.

    If you still have trouble with this, I recommend using PHPMailer to send your e-mails. It's really easy to use and has a lot of functions, such as SSL and TLS or Attachments in e-mails.

    评论

报告相同问题?

悬赏问题

  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭
  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂
  • ¥15 wordpress 产品图片 GIF 没法显示