The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

RobertGloverJr (30) [Avatar] Offline
#1
I think it would be helpful if Section 14.3 (Sending Email) were enhanced to explain how to add multiple recipients, and then go the extra mile and discuss what to do if any of the multiple recipients are properly formatted but refer to non-existent email addresses.

My own experience when the mail server is Lotus Notes Domino server and an invalid email address is in the list of recipients, is that it causes the following exception to be thrown and cancels the entire email from being sent:

com.sun.mail.smtp.SMTPAddressFailedException: 550 SpitterFoo.IDoNotExist@www.spittle.org... No such user

This kind of detail that nobody else thinks to mention would help make this book even more special.

.
RobertGloverJr (30) [Avatar] Offline
#2
Re: Section 14.3 Sending Email -- com.sun.mail.smtp.SMTPAddressFailedException
In "old" Spring the solution is found by referring to the complete listing of Java Mail Properties at http://www.java-email.com/content/view/38/60/ and then using that as a guide add the following javaMailProperty to the configuration of org.springframework.mail.javamail.JavaMailSenderImpl :

key: mail.smtp.sendpartial
value: true

(by default, property mail.smtp.sendpartial is set to false)

.
RobertGloverJr (30) [Avatar] Offline
#3
Re: Section 14.3 Sending Email -- com.sun.mail.smtp.SMTPAddressFailedException
When that Java Mail Property is set to true, an exception is still thrown, but despite the exception being thrown the email will still be sent. When the property is false (the default), the entire email is canceled and not sent.

The exception when caught is of class org.springframework.mail.MailSendException.

When "getMessage() is issued against the exception, the following appears:

com.sun.mail.smtp.SMTPSendFailedException: 250 Mail queued for delivery.
nested exception is:
com.sun.mail.smtp.SMTPAddressFailedException: 550 SpitterFoo.IDoNotExist@www.spittle.org... No such user
com.sun.mail.smtp.SMTPAddressFailedException: 550 SpitterFoo.IDoNotExistToo@www.spittle.org... No such user

I wrote a routine that uses RegExp to parse that message and create an Array containing all the bad email addresses. Maybe that is overkill, or maybe it would be useful to expand the example to include that too.

.