我使用以下代码发送包含嵌入图像的HTML电子邮件:
HtmlEmail email = new HtmlEmail();
email.setCharset("utf-8");
String html=....;
String txt=....;
Map map=new HashMap();
map.put("charset",CHARSET);
map.put("List-Unsubscribe","<mailto:abc@example.com>, <https://example.com/");
map.put("X-property", property);
email.setHeaders(map);
email.setHostName(HOSTNAME);
email.setSmtpPort(PORT);
email.setFrom(from, fromname);
email.setBounceAddress(frombounce);
email.setSubject(subject);
Iterator<String> it=inlineImages.iterator();
URL url=null;
String cid = "";
String imgurl ="";
while (it.hasNext())
{
imgurl=it.next();
url = (getPathFromLocalFile(imgurl));
cid = email.embed(url, getName(imgurl));
html=StringTools.replace(html,imgurl,"cid:"+cid);
}
email.addTo(to);
email.setTextMsg(textbody);
email.setHtmlMsg(htmlbody);
email.setHostName(HOSTNAME);
.....
email.setSubject(subject);
email.send();
代码工作正常,因为我最终收到了一封精美的电子邮件。图像是嵌入的,在Thunderbird中,用户立即看到带有图像的正确html。 但是,有些客户无法正常工作。这些是Outlook,K9-Mail for Android或Roundcube。在这里,我看到附件的回形针符号。尽管如此,邮件看起来很棒,所以无需按下按钮即可下载。邮件的内容类型可能有问题,但我不确定。
有人能看到什么错误吗?
编辑: 标题为纯文本。
Return-Path:X-Spam-Checker-Version:SpamAssassin 3.4.0(2014-02-07)on test@example.com X-Spam-Level:X-Spam-Status:No,score = -1.9 required = 4.0 tests = BAYES_00,FREEMAIL_FROM, HTML_MESSAGE,RCVD_IN_MSPIKE_H2,SPF_PASS,URIBL_BLOCKED autolearn = ham autolearn_force = no version = 3.4.0 X-Original-To:test@example.com Delivered-To:test@example.com收到:来自mout.example.net (mout.example.net [77.77.77.77])(使用带密码的TLSv1.2 DHE-RSA-AES256-GCM-SHA384(256/256位))(无客户端证书 请求)mail.example.eu(Postfix)与ESMTPS id 7275A7AB8687 为2016年6月10日星期五15:41:56 +0200(CEST) 收到:来自mail.example.com的示例([77.77.77.77]) (mrexample001)与ESMTPSA(Nemesis)id 0Lw2Sj-1bWOaM07n3-017j0o for ; 2016年6月10日星期五15:41:55 + 0200日期:6月10日星期五 2016 15:41:47 +0200(CEST)来自:Testaccount von示例 收件人:test@example.com消息ID: &LT; 809223752.3.1465566107118.JavaMail.user@example>学科: =?UTF-8?Q?Sch = C3 = BCtzen_Sie_sich_mit_unanfec?= =?UTF-8?Q?= MIME-Version:1.0 Content-Type:multipart / mixed;
边界=&#34; ---- = _ Part_0_1010418160.1465566107019&#34; charset:utf-8 X-Customer:12u890812792 List-Unsubscribe :, https://example.com/method=unsubscribe&email=12u890812792&unsubscribe=true X-Provags-ID: V03:K0:+ WezTQKC0rV + I + / Dkvjm1Zp0 + w6o6ZGZNXBvIMdU0ANaUTEIxow 63iaYyDyxW74ZNkXdFRiDea9DyQdordqCoprE2tJEhtDIS + ceHt + Q9eb + tSCyf1ADE6bZja NDJKYXWJdW0NeAZydDcVP / 8Er5knlmumhlyEhlnjFGmqbiBuO4wP3KqqC3vkh5rYFVaZe9V pM8Mox3lSMx4V / gh7Tp0g == X-UI-Out-Filter结果: notjunk:1; V01:K0:twqiq4jOtPg =:bALN2jRhEVBD8MkqJgqyHi FerpGKfqCgKcqiw2MdjebvuPKTI12CaGUIBMBiionmrMEmEXNENQNV / xK6b + 8QAYHLixWQqZc TC9lJFf8r2OcEpyNnFlNTHm8c / B / GbbOR / TUfk9W487HaXattRdnfsiZH / eFRiPcGB9y4gtZY G03G7U0rFPTcIvvHG10Ubc5eWq7v + Ptm6G9emlihE0Axc0flWW8K / j8Xat1l5KZ2OksQFrSAH YJlOEmoQM87W56bpqmZ + 3T8 / qUVDpdrV5KTdf0Y6wekk4lB3Po421sddZALqvWWZbWPBHS5Ce gFyTSfT55Gc38mDtoEABkWWJC7n15yci / MXkcHzvyHswMli3pGu6Gv5YteG6w0aVHP2FTtNgJ NN / 6aWdDITy8SVr03WdWKN + aNERwt79aTVorOE5RBqDuYk7DN8i190nNEEfgL1dRjF + Zx时+ 31O Xvh6rYSN1anm7CxVC06VbstGLY6Rrq0Ore + 5S + OBV + X20FL / ao2LwqtJ96EiRcKsO1H + T5t1F HEEscuUO0yASaWDxXVb + uoYy06IwgITc0TwuLZ1qGUxtIIIy4CIvZEw68CbAih3BFstV8zRid DLFrdHtf + hBfon1P4uRp5kkyB + 47w7G1Or3bPISqp / zhdq7LsYbFP5AuwXzGcQdP7IPAbeIGp oGUCTm74nqITGbfW / jqV27c1viJn3GEGHt90HmyYNJHqGS / dW2wiaeQhgIV + WP / Pm7cb / GwgB qAx54 / FxoLO4nR5wvLqcUNlsO1t7xepEBl5puvmWyLZR ++ AsnEhcK / 6ZqdQ = X-Virus-Status:没有X-Virus-Checker-Version:clamassassin 1.2.4 with clamdscan / ClamAV 0.98.7 / 21704 / Fri Jun 10 11:44:45 2016 X-Spambayes-分类:火腿; 0.03 X-Virustotal-Status:No X-Virustotal-String:#not checked:none / text / plain#not checked:none / text / html#not 选中:1465566109864.png / image / png#not 选中:1465566121103.png / image / png#not 选中:1465566117059.png / image / png#not 选中:1465566110651.png / image / png#not 选中:1465566109052.png / image / png#not 选中:1465566113630.png / image / png#not 选中:1465566121054.png / image / png#not 选中:1465566115535.png / image / png#not 选中:1465566109346.png / image / png#not 选中:1465566114750.png / image / png#not 选中:1465566108289.png / image / png#not 选中:1465566113027.png / image / png#not 选中:1465566115345.png / image / png#not 选中:1465566117438.png / image / png#not 检查:1465566119754.png /图像/ PNG