sargue / mailgun

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

Batch Send - Recipient Support #24

Closed pgali closed 6 years ago

pgali commented 6 years ago

According to maligun documentation, we can send the same message to several recipients. https://documentation.mailgun.com/en/latest/user_manual.html#batch-sending

Is there a way we can leverage that in your library? It doesn't make sense to make N http calls for N clients.

May be the code already exists and I am not aware. But I couldn't locate it. Any help will be greatly appreciated.

sargue commented 6 years ago

Just add as many to() chained calls (or cc()) as you want.

Mail.using(configuration)
    .to("marty@mcfly.com")
    .to("george@mcfly.com")
    .cc("lorraine@mcfly.com")
    .cc("dave@mcfly.com")
    .subject("This is the subject")
    .text("Hello world!")
    .build()
    .send();