We have a thread program that sends bulk mail. The information like
1. To
2. Subject
Etc.
are fetched from database, mail is composed and pushed to SMTP server. One of our customer sent a bulk mail with 2390 email. After sending 40 emails, suddenly the following exception occurred
EXCEPTION
javax.mail.AuthenticationFailedException
STACKTRACE
javax.mail.Service.connect(Service.java:306)
javax.mail.Service.connect(Service.java:156)
javax.mail.Service.connect(Service.java:105)
...............
java.lang.Thread.run(Thread.java:619)
and the rest 2350 emails failed.
Why does this occur?
Thanks for the Suggestions and Help
Ezhil
==============================================
My Code:
Session session = Session.getInstance(properties, new SMTPAuthenticator(smtpAuthenticationBean.getUserName(), smtpAuthenticationBean.getPassword()))) : (Session.getInstance(properties, null))
for each email id
{
InternetAddress iAddress = new InternetAddress(getFromHeader(jobListBean.getFromDisplayName(), jobListBean.getFromEmail()));
Multipart multipart = new MimeMultipart(); // By default, Content Type is "mixed"
msg.setSubject(jobListBean.getSubject());
msg.setSentDate(new Date());
// Set Internet Headers
msg.setHeader("Importance", priorityType);
msg.setHeader("Disposition-Notification-To", jobListBean.getFromEmail());
FileDataSource fds = new FileDataSource(tempAbsoluteFileName);
MimeBodyPart htmlBodyPart = new MimeBodyPart();
String fileContent = org.objectstyle.woproject.util.FileStringScanner.stringFromFile(new File(tempAbsoluteFileName));
htmlBodyPart.setText(fileContent);
multipart.addBodyPart(htmlBodyPart);
msg.setContent(multipart);
InternetAddress address[] = InternetAddress.parse(emailList.toString(), true);
Transport smtpTransport = session.getTransport();
smtpTransport.addTransportListener(this);
smtpTransport.connect();
smtpTransport.sendMessage(msg, address);
smtpTransport.close();
File file = new File(tempAbsoluteFileName);
file.delete();
}
====================================
Yes there is a chance for smtp server to get disconnected or not respond since its thread program, i can say at max case more than 1000 mails can get pushed in to smtp server at same time.
At any cast, will smtp server throw
EXCEPTION
javax.mail.AuthenticationFailedException
STACKTRACE
javax.mail.Service.connect(Service.java:306)
javax.mail.Service.connect(Service.java:156)
javax.mail.Service.connect(Service.java:105)
...............
java.lang.Thread.run(Thread.java:619)
if it is not able to serve our request
=============
Still i need to look in to SMTP server log.
Ezhil