0
希望有人能找到我失蹤的東西。我正嘗試在Java應用程序中發送簡單的HTML電子郵件。我使用commons-mail 1.1(通過maven)作爲我的郵件庫。HtmlEmail不能正確呈現HTML(apache commons)
我正在使用的代碼是:
HtmlEmail email = new HtmlEmail();
email.setDebug(true);
email.setHostName("my.emailhost.com");
email.addTo("[email protected]");
email.setFrom("[email protected]");
email.setSubject("Test Subject");
email.setHtmlMsg("<b>This is a bolded message</b>");
email.setTextMsg("This is a text message");
email.send();
我收到的電子郵件,但它正是如此格式化。還應該指出的是,沒有主題,但我明顯在我的代碼中指定了一個主題。
------=_Part_0_122395252.1304699110505
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
This is a text message
------=_Part_0_122395252.1304699110505
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit
<b>This is a bolded message</b>
------=_Part_0_122395252.1304699110505--
我不知道我在做什麼錯在這裏。我切換到通過gmail發送 - 它確實發送,它只是格式化它完全相同。當我查看我看到的原始消息時
Delivered-To: [email protected]
Received: by 10.90.73.11 with SMTP id v11cs143993aga;
Fri, 6 May 2011 09:25:11 -0700 (PDT)
Received: by 10.236.187.97 with SMTP id x61mr4380232yhm.476.1304699111088;
Fri, 06 May 2011 09:25:11 -0700 (PDT)
Return-Path: <[email protected]>
Received: from xxxxxxx.xxxxxxx.com (xxxxxxx.xxxxxxx.com [x.x.x.x])
by mx.google.com with ESMTP id 68si9400486yhl.82.2011.05.06.09.25.10;
Fri, 06 May 2011 09:25:10 -0700 (PDT)
Received-SPF: pass (google.com: domain of [email protected] designates x.x.x.x as permitted sender) client-ip=x.x.x.x;
Authentication-Results: mx.google.com; spf=pass (google.com: domain of [email protected] designates x.x.x.x as permitted sender) [email protected]
Received: from xxxxxxx-mac-pro.local ([x.x.x.x])
by xxxxxxx.xxxxxxx.com (Lotus Domino Release 8.5.1FP3)
with ESMTP id 2011050612251028-17357 ;
Fri, 6 May 2011 12:25:10 -0400
From: [email protected]
Date: Fri, 6 May 2011 12:25:10 -0400
Message-ID: <[email protected]>
任何想法將不勝感激。
乾杯