ClassCastException: class org.apache.camel.component.directvm.DirectVmEndpoint cannot be cast to class org.apache.camel.component.mail.MailEndpoint
This is caused by:
Which assumes the exchanges endpoint is always a MailEndpoint.
This piece of code from DefaultUnitOfWork will trigger the init of headers:
If message is of type MailMessage, it will be delegated there:
This works for the initial route with a from imaps, but in a subroute the error occurs.
Possible solution could be to pass a reference to either the mail endpoint or mail configuration to the binding on create/set.