sargue / mailgun

Java library to easily send emails using the Mailgun service
MIT License
152 stars 40 forks source link

adding header #17

Closed adhinugroho1711 closed 7 years ago

adhinugroho1711 commented 7 years ago

hello,

can i add header on email? if yes, how to add?

thankyou

sargue commented 7 years ago

Yes, you can add custom headers to the outgoing email. Just use the parameter(String,String) method of the MailBuilder class and send a parameter starting with ' h:' as explained in the mailgun documentation.

MailBuilder.using(configuration)
            .to("marty@mcfly.com")
            .subject("This is a plain text test")
            .text("Hello world!")
            .parameter("h:CustomHeader", "The header value")
            .build()
            .send();

The above example will add a header named CustomHeader to the message.