Reputation: 28555
I am needing to do some automatic email sending daily on a daily basis to say...for the sake of simplicity 1000 messages. What is the best way to accomplish this using java?
The plan of action right now is to basically just run a loop and send the messages one by one. Should I be taking a more complex approach using multiple threads, or somehow batching messages? I admit I am a total noob when it comes to managing email so I am more or less just looking for some suggestions to get me started.
Upvotes: 2
Views: 5155
Reputation: 69339
There are some helpful libraries out there, for example the Apache Commons Email project (find examples here).
I wouldn't overly concern yourself about multiple threads unless performance is an issue, which is normally isn't for batch email jobs.
Upvotes: 1
Reputation: 89169
With JavaMail, you can open a mail Session
and send all your MimeMessage
(as many as you want) and when you're done, close the Session
. No need to keep opening a session, send a message and close.
Upvotes: 1