I'm using Apache Camel 2.22.0 and have a simple route that is sending an email (with a few property references):
public class EmailFailureRoute extends RouteBuilder {
@Override
public void configure() {
from("seda:mail")
.setHeader("To", simple("{{mail.failure.to}}"))
.setHeader("From", simple("{{mail.failure.from}}"))
.setHeader("Subject", constant("TEST!"))
.to("velocity://templates/failure-mail.vm")
.to("{{mail.smtpServer}}");
}
}
What I expect to get is a normal email with the text from the Velocity template in the body of the message. What I actually get is an email with the text from the Velocity template attached to the email. It looks like this in MS Outlook:
Why the attachment? How do I get the mail component to insert the result of the Velocity template directly into the email message body?
UPDATE:
By turning on the 'debugMode' flag on the mail component, I was able to see the content of the actual email as it's being sent to the SMTP server. It appears that my problem is that the Content-Type is 'application/json'! So now it makes sense that the body is attached but I have no idea why the Content-Type is set this way. Even setting the query parameter 'contentType=text/plain' on the mail end point has no effect on the final Content-Type of the email message.