commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Nweike Onwuyali <nweikeonwuy...@gmail.com>
Subject [email]-Cannot send mail embedded with image from my Play Framework
Date Thu, 23 Apr 2015 07:59:08 GMT
Hi,
I am a newbie and started using commons email only a few days ago.I am able
to send mail with html content successfully. But when i tried to embed an
image like a logo, i get the following error
++++++++++++++++++++++++++++++++++++++++++++++
java.lang.NullPointerException
org.apache.commons.mail.ImageHtmlEmail.replacePattern(ImageHtmlEmail.java:151)
[error] play - Cannot invoke the action, eventually got an error:
java.lang.Exception: java.lang.NullPointerException
at
org.apache.commons.mail.ImageHtmlEmail.buildMimeMessage(ImageHtmlEmail.java:105)
at org.apache.commons.mail.Email.send(Email.java:1436)
at utils.Mailer.sendMail(Mailer.java:65)
at controllers.Users.save(Users.java:64)
++++++++++++++++++++++++++++++++++++++++++++++
Below is my code:

HtmlEmail email = new ImageHtmlEmail();

URL logoURL = new URL(mailDetails.get("logoURL").toString());
String cidlogo = email.embed(logoURL, "Ziphii logo");
email.setHtmlMsg("<html>The apache logo - <img
src=\"cid:"+cidlogo+"\"></html>");

String[] to = (String[]) mailDetails.get("recipient");
String[] from = (String[]) mailDetails.get("from");
String[] credentials = (String[]) mailDetails.get("credentials");

email.setHostName(mailDetails.get("hostName").toString());
email.setSmtpPort(Integer.parseInt(mailDetails.get("hostPort").toString()));//587
email.setAuthentication(credentials[0], credentials[1]);

email.addTo(to[0], to[1]);
email.setFrom(from[0],from[1]);
email.setSubject(mailDetails.get("subject").toString());

 email.setTextMsg(mailDetails.get("alternativeRouteUrl").toString());
 email.setDebug(true);
 email.send();

+++++++++++++++++++++++++++++++++++++++++++

I am using a Play! Framework and i am in dev mode.

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message