Reputation: 55
I'm trying to send custom email headers in emails from mule.
Adding a static header in the
<smtp:connector>
definition as
<smtp:header key="headerKey" value="headerVal">
is easy but I need to make the header values different for every email I'm sending with
<smtp:outbound-endpoint>
Can this be done with Mule's SMTP component?
Upvotes: 0
Views: 291
Reputation: 55
I have solved the problem by adding a custom transformer to the smtp outbound endpoint.
public class EmailTransformer implements MessageTransformer {
@Override
public MuleEvent process(MuleEvent event) throws MuleException {
...
SmtpConnector conn = (SmtpConnector)event.getMuleContext().getRegistry().lookupConnector("SMTP");
if (conn != null) {
conn.getCustomHeaders().put("headerName", headerValue);
}
}
}
The transformer reads the values in the variables and sets the headers in the transformer's process method. Not very elegant but gets the job done.
Upvotes: 0