• Post Reply Bookmark Topic Watch Topic
  • New Topic

MessageException problem?  RSS feed

 
Mandy Hou
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys:
I writed a method to send 150 same emails like this:

Transport transport = mailSession.getTransport("smtp");
transport.connect(MailAuthenticator.HOST, MailAuthenticator.USER, MailAuthenticator.PASSWORD);

.....
.....
for(int i = 0; i<150; i++){
transport.sendMessage(msg,msg.getAllRecipients());
}

I meet the MessageException when I send 25 emails:
421 resources temporarily unavailable. Please try again later.

is that mean the mail server is busy? why does this exception appeare after sent 25 emails everytime? I need your help, thanks!

Mandy
 
Masoud Kalali
Author
Ranch Hand
Posts: 531
Java Mac OS X Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
perhapss the server do not like you to send several emails one after the other.
maybe it assume that you are trying to send spams, i think the server is configured not to allows any client? to send more than 25 message in an specefic timeframe
 
Mandy Hou
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Masoud

I am agree with you!

Before I sent only one email with one transport, but it is very slow to create and init one transport. Since that I determine to send more emails with one transport. It is more quick than before. And than I meet the problem you see in the topic. To resolve it I start to use arithmometer. When one transport sent 20 emails ,a new transport will be created and continue the work. Now it can work correctly and quickly!

But I think I will encounter another problem: Now the email server can allow one transport to send 25 emails, but maybe someday the number will change to 20 or 15,and than that problem will appeare again! So I need a method to catch the exception resolve the problem! Do you have any good idea?

Thanks
Mandy
 
Masoud Kalali
Author
Ranch Hand
Posts: 531
Java Mac OS X Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
The real solution is to find an SMTP that gives you enough credit to send your emails.

but for a temporary solution :
-Store 20 in a configuration holder like Properties file , xml , .. , we name it X
-start sending email , but initiate the loop parameter to send only X emails , you should read x before you start the job.
-if you face an exception store the loop value-1 to configuration file , and create another transporter.

-continue sending email.


in this way you are allways updated with maximum allowd sends , but its drawback is that you will never beware that you can semd more emails with a transporter , because you never pass the maximum number that you stored.
[ May 19, 2006: Message edited by: Masoud Kalali ]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!