Sending multi-part email from Google App Engine using Spring's JavaMailSender fails
- by hleinone
It works without the multi-part (modified from the example in Spring documentation):
final MimeMessagePreparator preparator = new MimeMessagePreparator() {
public void prepare(final MimeMessage mimeMessage) throws Exception {
final MimeMessageHelper message = new MimeMessageHelper(
mimeMessage);
message.setTo(toAddress);
message.setFrom(fromAddress);
message.setSubject(subject);
final String htmlText = FreeMarkerTemplateUtils
.processTemplateIntoString(configuration
.getTemplate(htmlTemplate), model);
message.setText(htmlText, true);
}
};
mailSender.send(preparator);
But once I change it to:
final MimeMessagePreparator preparator = new MimeMessagePreparator() {
public void prepare(final MimeMessage mimeMessage) throws Exception {
final MimeMessageHelper message = new MimeMessageHelper(
mimeMessage, true);
...
message.setText(plainText, htmlText);
}
};
mailSender.send(preparator);
I get:
Failed message 1:
javax.mail.MessagingException: Converting attachment data failed
at com.google.appengine.api.mail.stdimpl.GMTransport.sendMessage(GMTransport.java:231)
at org.springframework.mail.javamail.JavaMailSenderImpl.doSend(JavaMailSenderImpl.java:402)
...
This is especially difficult since the GMTransport is proprietary Google class and no sources are available, which would make it a bit easier to debug. Anyone have any ideas what to try next?
My bean config, for helping you to help me:
<bean id="mailSender" class="org.springframework.mail.javamail.JavaMailSenderImpl"
p:username="${mail.username}" p:password="${mail.password}"
p:protocol="gm" />