I am trying to use the camel-mail component to send emails from my application using Amazon Simple Email Service. The reason that I am trying to use the camel-mail component not the camel-ses component is that camel-ses does not support attachments.
I am using this to uri:
smtp://$smtpHost:$smtpPort?username=$smtpUsername&password=$smtpPassword&mail.smtp.ssl.enable=true&mail.smtp.ssl.required=true&mail.smtp.auth=true
But I get the error at run-time:
com.sun.mail.smtp.SMTPSendFailedException: 554 Transaction failed: Illegal header 'breadcrumbId'.
at com.sun.mail.smtp.SMTPTransport.issueSendCommand(SMTPTransport.java:2114)
at com.sun.mail.smtp.SMTPTransport.finishData(SMTPTransport.java:1900)
at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:1122)
at org.apache.camel.component.mail.DefaultJavaMailSender.send(DefaultJavaMailSender.java:124)
at org.apache.camel.component.mail.MailProducer.process(MailProducer.java:49)
So it appears that Amazon are quite strict about what headers can be sent and Camels approach doesn't play nicely with SES:
Camel copies all of the exchange's IN headers to the MimeMessage headers.
Digging in to the Source, I can see that the class org.apache.camel.component.mail.MailBinding
has constructor which accepts a HeaderFilterStrategy
:
public MailBinding(HeaderFilterStrategy headerFilterStrategy, ContentTypeResolver contentTypeResolver) {
this.headerFilterStrategy = headerFilterStrategy;
this.contentTypeResolver = contentTypeResolver;
}
How can I configure camel-mail to use a custom HeaderFilterStrategy
?