java - How to find out an email is bounced with Spring's MailSender -


i sending emails through gmail. sends emails, when enter wrong email address not throw exception; however, email sent me.

i changed email configuration , threw authentication exception not throw sendmail exception wrong email addresses.

try {         simplemailmessage message = new simplemailmessage();         message.setto(receiveremail); //the value xc@cvcbdfgxcvwesdc.org         message.setcc(myemailaddress);         message.setsubject(subject);         message.settext(msg);         mailsender.send(message);      } catch (mailsendexception send) { //i used mailexception         send.printstacktrace();     } 

i added following code not show anything

} catch (mailsendexception send) { // failed send /there 1 other                                             // type of exception             system.err.println("failed messages size:" + send.getfailedmessages().size()); 

the mailsender won't able determine if email bounced in sense imagine, @ least not during send process. code there tell if there exception within code prevents sending email.

bounced email response hit mail server, in case need implement mechanism such mail-receiving channel adapter http://docs.spring.io/spring-integration/reference/html/mail.html.

only when read bounced email mail server can determine reason failure , determine appropriate response.

hope helps bit.


Popular posts from this blog