I'm trying to send an e-mail using Google App Engine. I'm getting the exception below and I'm not sure why at the moment. Any ideas?
javax.
mail.SendFailedException: Send failure (javax.
mail.MessagingException: Illegal Arguments (java.lang.IllegalArgumentException: Bad Request: Invalid sender format))
at javax.
mail.Transport.send(Transport.java:163)
at javax.
mail.Transport.send(Transport.java:48)
at com.mystuff.service.
mail.MailService.sendActivationEmail(MailService.java:145)
Below is the code related to sending the e-mail.
public final void sendActivationEmail(final UserAccount user) {
final Properties props = new Properties();
final Session session = Session.getDefaultInstance(props, null);
final Message message = new MimeMessage(session);
final Multipart multipart = new MimeMultipart();
final MimeBodyPart htmlPart = new MimeBodyPart();
final MimeBodyPart textPart = new MimeBodyPart();
final Locale locale = LocaleContextHolder.getLocale();
try {
message.setFrom(new InternetAddress(getFromAddress(), "Qoogeo"));
message.addRecipient(Message.RecipientType.TO,
new InternetAddress(user.getUsername(),
user.getFirstName() + " " + user.getLastName()));
message.setSubject(messageSource.getMessage("
mail.subject", null,
locale));
textPart.setContent(messageSource.getMessage("
mail.body.txt",
new Object[] {getHostname(), user.getActivationKey()}, locale),
"text/plain");
htmlPart.setContent(messageSource.getMessage("
mail.body.html",
new Object[] {getHostname(), user.getActivationKey()}, locale),
"text/html");
multipart.addBodyPart(textPart);
multipart.addBodyPart(htmlPart);
message.setContent(multipart);
Transport.send(message);
} catch (MessagingException e) {
LOGGER.warn(ERROR_MSG, e);
} catch (UnsupportedEncodingException e) {
LOGGER.warn(ERROR_MSG, e);
}
}
Also, getFromAddress() returns "
[email protected]".