simple-java-mail
simple-java-mail copied to clipboard
Email not sending when using asynchronous feature
When using mailer.sendMail(email, /* async = */ true); or Mailer mailer = mailerBuilder.(..).async().buildMailer(); to send async emails it seems to send no emails when tested and there seems to be no errors that are indicated when testing too. When I send a normal email that is not async it seems to send no problem so Im not sure why the async email is not able to send. https://www.simplejavamail.org/features.html#section-sending-asynchronously
This is one of the most used features so I'm a little skeptical, but let's see. Which version are you on? You can take the result of sendMail() and handle it's async result, have you tried that? Also, are you catching and swallowing any exception by chance?
Im on version 7.1.0. I am not catching any exceptions at the moment.
So what do you get when you configure a result handler, like so:
mailer.sendMail(email, true)
.whenComplete((result, ex) -> {
if (ex != null) {
System.err.printf("Execution failed %s", ex);
} else {
System.err.printf("Execution completed: %s", result);
}
});
when i configure the handler like that it gets neither execution failed nor complete. When i get rid of the true for sendmail to make it sync it says execution completed null for some reason
Do you have logging enabled? If you add something like logback/log4j2 to your test, you can see what Simple Java Mail is doing. See here for more details on this.
i did add log4j2 to my test but it seems to still not output anything, the ex exception seems to be empty rather than null
I'm not sure where to go from here. You report one of the core and most used features is not working, you don't have errors and you don't have relevant logging. That's not much to go on. Closing until I'm convinced this is not a user error.