Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Java Mail API !!!!!!!!!!!!!

 
Anoop Krishnan
Ranch Hand
Posts: 163
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I need an application which has to send 400000 mails in 2 hours
is Java Mail API can handle this requirement or is there any other API available
 
Detlev Beutner
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I just tested the performance with a very simple program:

It takes... about 50(!) seconds to send this 50 mails! This for sure also depends on the mail-server (in this case it is an MSEX) and some other circumstances, but it indicates that it should be a really hard task to achieve your goal...
As you realize, I did not try anything to speed up the sending; for performance questions (and some other) have a look at http://developer.java.sun.com/developer/community/chat/JavaLive/2000/jl1212.html (interview about JavaMail 1.2)
On the other hand, it is less a question of "another" mail-api but a question of the possible use of an other SMTP-provider (I used the SUN-implementation; but on http://java.sun.com/products/javamail/Third_Party.html there is no other).
But: Have a look at http://oss.software.ibm.com/developerworks/projects/smtp and try out, maybe this helps (even if I do not like do leave the sun-path...)
Hope it helps
Detlev
[This message has been edited by Detlev Beutner (edited July 20, 2001).]
 
Chuck Lorenz
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Will you get better results if you replace with ? I don't know from personal experience (too new to the API), but the short course from JGuru on the Fundamentals of the JavaMail API seems to imply it.
Transport
The final part of sending a message is to use the Transport class. This class speaks the protocol-specific language for sending the message (usually SMTP). It's an abstract class and works something like Session. You can use the default version of the class by just calling the static send() method:
Transport.send(message);
Or, you can get a specific instance from the session for your protocol, pass along the username and password (blank if unnecessary), send the message, and close the connection:
message.saveChanges(); // implicit with send()
Transport transport = session.getTransport("smtp");
transport.connect(host, username, password);
transport.sendMessage(message, message.getAllRecipients());
transport.close();
This latter way is best when you need to send multiple messages, as it will keep the connection with the mail server active between messages. The basic send() mechanism makes a separate connection to the server for each method call.

Chuck
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic