Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
JackHewson opened this issue Sep 29, 2021 · 2 comments

Comments

@JackHewson
Copy link

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!

@bbottema
Copy link
Owner

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.

@bbottema bbottema added this to the 6.7.5 milestone Dec 26, 2021
@bbottema bbottema changed the title Receiving messageID (.getId()) when using .async()? Also return AsyncResponse from plain Mailer.sendEmail(singleArgument) as async can be configured through MailerBuilder now Dec 26, 2021
bbottema added a commit that referenced this issue Dec 26, 2021
…nt), as async can now be configured through the mailerBuilder as well
@bbottema
Copy link
Owner

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants