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

MailException is not thrown for sending failures, only (apparently) data issues #160

Closed
johnchurchill opened this issue Aug 19, 2018 · 3 comments
Labels

Comments

@johnchurchill
Copy link

Hi,
Nice library. It really simplifies my client code and even makes image embedding a no-brainer.
My problem is that if the SMTP server is down or unreachable, themailer.sendMail(email, async) method doesn't throw an exception. Instead, it just logs the error and lets me move on.
It's pretty embarrassing if a user is told that an email is coming but it never does. So, what I need to do is fall back to two other SMTP servers which are likely to work in case the first one fails.
Is there a setting or workaround I'm missing somewhere?

@bbottema
Copy link
Owner

bbottema commented Aug 20, 2018

Is there a setting or workaround I'm missing somewhere?

That depends on how you call mailer.sendMail(email, async), async being true or false:

  • async false: it should definitely throw an exception. This has been tested thoroughly so if you don't get an exception I would really like to know how you are using the library so I can fix it.
  • async true: it will not throw an exception, because it wouldn't be an async process if the parent thread has to wait for the outcome (unfortunately, I didn't think of the unhappy flow at the time). Fortunately, this problem has been fixed in Provide a way to handle success/failure in async mode (including testConnection()) #148 (Provide a way to handle success/failure in async mode) for release 6.0.0, but has not yet been released.

If you are in a hurry, what I can do for you is update the 6.0.0.beta-SNAPSHOT with the latest changes including #148. Otherwise, if you wish to asynchronously send emails, you will need to manage your own thread pool and use the async=false instead.

Let me know your decision!

@johnchurchill
Copy link
Author

Hi Benny,
Thanks for the quick response. My apologies, it really is throwing the exception in sync mode, and I can also get the cause. I was running a mock on my emailer client and for some reason the messages to the logger are being lost, leading me to think that no exception was being thrown.
And no, I'm not in any big hurry. I can set this up with my own thread to fall back to a local SMTP server in case the main one fails.
Thanks again!
John

@bbottema
Copy link
Owner

Alright, no worries! Let me know if you run into trouble again...

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

No branches or pull requests

2 participants