|
|
|
|
Re: Using javamail for SMPTS on virgo fails on typo [message #1115214 is a reply to message #1078740] |
Mon, 23 September 2013 21:05 |
Eduardo Frazão Messages: 123 Registered: January 2012 |
Senior Member |
|
|
Here im using javax.mail 1.4.0.v201005080615
The default one, that comes with Virgo 3.6.2
I'm using apache Commons Mail Facade API too.
To create Multipart emails, with attachments, etc, I got some problems, and I solved it in this way:
-- Ive created a EmailService Facade
public EmailServiceImpl() {
MailcapCommandMap mc = (MailcapCommandMap) CommandMap.getDefaultCommandMap();
mc.addMailcap("text/html;; x-java-content-handler=com.sun.mail.handlers.text_html");
mc.addMailcap("text/xml;; x-java-content-handler=com.sun.mail.handlers.text_xml");
mc.addMailcap("text/plain;; x-java-content-handler=com.sun.mail.handlers.text_plain");
mc.addMailcap("multipart/*;; x-java-content-handler=com.sun.mail.handlers.multipart_mixed");
mc.addMailcap("message/rfc822;; x-java-content-handler=com.sun.mail.handlers.message_rfc822");
CommandMap.setDefaultCommandMap(mc);
}
And, to send emails:
public void send(Email email, EmailAccount account) {
final ClassLoader tcl = Thread.currentThread().getContextClassLoader();
try {
Thread.currentThread().setContextClassLoader(javax.mail.Session.class.getClassLoader());
org.apache.commons.mail.Email e = createImplEmail(email, account);
e.send();
}
catch (Exception e) {
logSevere("Unable to send", e);
throw new DomainException("exceptionI18nID", "Unable to send");
} finally {
Thread.currentThread().setContextClassLoader(tcl);
}
}
|
|
|
Powered by
FUDForum. Page generated in 0.04071 seconds