【发布时间】:2012-08-09 20:59:17
【问题描述】:
尝试玩游戏!发送带有附件的电子邮件的框架。如果我不将附件添加到邮件中,下面的代码可以正常工作。我已经尝试过使用 Play 的 Mailer 类和 Apache Commons 类(如下所示),但在这两种情况下,页面都只是用微调器(Chrome)坐在那里,没有收到任何电子邮件。
EmailAttachment attachment = new EmailAttachment();
attachment.setURL(new URL(base + "public/images/triangles.png"));
attachment.setDisposition(EmailAttachment.ATTACHMENT);
attachment.setDescription("test");
attachment.setName("test");
emailaddress = "test@test.com";
MultiPartEmail email = new MultiPartEmail();
email.setDebug(true);
email.addTo(emailaddress);
email.setFrom("Testing <test@test.com>");
email.setSubject("Testing email");
try
{
email.attach(attachment);
}
catch (EmailException ex)
{
System.out.println(ex.getMessage());
}
email.setMsg("test email");
email.send();
【问题讨论】:
标签: java playframework apache-commons-email