bbottema / simple-java-mail

Simple API, Complex Emails (Jakarta Mail smtp wrapper)

Home Page:http://www.simplejavamail.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Also return AsyncResponse from plain Mailer.sendEmail(singleArgument) as async can be configured through MailerBuilder now

JackHewson opened this issue · comments

According https://www.simplejavamail.org/features.html#section-sent-id it is possible to receive the generated messageId by:

mailer.sendMail(email); // id updated during sending!
email.getId(); // <1420232606.6.1509560747190@Cypher>`

But how is it possible to receive the messageId when using .async()?
When using .async(), the email.getId(); is null.

Thank you!

As the code to update and send is run asynchronously, you would have to use the completion handlers to know when the email was actually updated and set. These is currently only available from the method mailer.send(email, true):

mailerSMTPBuilder.buildMailer().sendMail(emailNormal, true)
	.onSuccess(() -> {});

or

mailerSMTPBuilder.buildMailer().sendMail(emailNormal, true).getFuture().get()

However, it does make sense to return the same from mailer.send(email), since it can now be configured on the builders. I'll think about adding that.

I've just released 6.7.5 which now returns AsyncResponse from mailer.sendMail(singleArgument). That should make it easier for you to handle the async exeution.