Monday, November 11, 2013

Camel Mail - Removing extra headers from email body

The camel-mail component may send extra headers in when sending email. The below route shows how to use the removeHeaders() function to remove the extra header information from the camel route.
Java DSL
from("vm:mailService")
.to("velocity:customMailTemplate.vm")
.process(new Processor() {
 @Override
 public void process(Exchange exchange) {
   Message message = exchange.getIn();
          message.setHeader(Exchange.CONTENT_TYPE, "text/plain");
 }
})
// Remove all headers, except the one reqd. by camel-mail component
.removeHeaders("*", "To", "Subject", "From")
.to("smtp://127.0.0.1");

No comments :

Post a Comment