Monday, June 01, 2009

Dev : Java Send Mail

Ever wonder why your application did not send the email out? Your code seems fine, but still fails. Single mail address is OK, but when coming to a list of emails, you're getting "550 5.1.1 User unknown" or some other error stating that one or more emails are not valid.

Well, this feature is actually intended by Sun. But I still want to send the email to the valid emails and how do we overcome this problem? Simple, by just added an extra line to the email property will do.

Normally, we would tell the mailserver what is the values for "mail.transport.protocol", "mail.smtp.host", "mail.host" and such, we just need to add in this "mail.smtp.sendpartial" and the value for it is true. With this, although the exception will still be thrown, but those with valid email will received the mail.

Of course, if you have cater for a resend if exception occurs, better check your code and list of emails. You would not want valid email owners keep on receiving the same mail over and over again. :)

No comments: