title: How to use a custom HeaderFilterStrategy with Apache Camel Email component
body: <p>I am trying to use the <a href="http://camel.apache.org/mail.html" rel="nofollow">camel-mail</a> component to send emails from my application using <a href="http://aws.amazon.com/ses/" rel="nofollow">Amazon Simple Email Service</a>. 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.  </p>
  
  <p>I am using this to uri:</p>
  
  <pre><code>smtp://$smtpHost:$smtpPort?username=$smtpUsername&amp;password=$smtpPassword&amp;mail.smtp.ssl.enable=true&amp;mail.smtp.ssl.required=true&amp;mail.smtp.auth=true
  </code></pre>
  
  <p>But I get the error at run-time:</p>
  
  <pre><code>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)
  </code></pre>
  
  <p>So it appears that Amazon are quite strict about what headers can be sent and Camels approach doesn't play nicely with SES:</p>
  
  <blockquote>
    <p>Camel copies all of the exchange's IN headers to the MimeMessage
    headers.</p>
  </blockquote>
  
  <p>Digging in to the Source, I can see that the class <code>org.apache.camel.component.mail.MailBinding</code> has constructor which accepts a <code>HeaderFilterStrategy</code>: </p>
  
  <pre><code>public MailBinding(HeaderFilterStrategy headerFilterStrategy, ContentTypeResolver contentTypeResolver) {
          this.headerFilterStrategy = headerFilterStrategy;
          this.contentTypeResolver = contentTypeResolver;
  }
  </code></pre>
  
  <p>How can I configure camel-mail to use a custom <code>HeaderFilterStrategy</code>?</p>