Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

javamail vs sendmail performance during bulk email [closed]

I'm writing a Java mass emailer application to send out emails to send between 50,000 to 100,000 a day to users.

The current plan is to delegate the sending to delegate to sendmail (on the local unix server).

From our testing sendmail is sending a maximum of 5 emails per second.

Would JavaMail be a faster option?

Does anyone know what a faster way to send emails. We want to get this process out as quick as possible.

Edit: BTW, a pdf will be attached too

like image 676
WellieeGee Avatar asked Dec 17 '22 04:12

WellieeGee


2 Answers

You're not comparing like with like. JavaMail talks SMTP to hand off to the nearest mail server. Sendmail is a Mail Transfer agent responsible for routing emails to their destination.

A common setup is a java application using JavaMail to relay email via SMTP to a Sendmail server. The two are not competitors, they're used together. A sendmail server should be able to accept deliveries from javamail faster than any java application can produce them, but then it delivers them asynchronously at its own rate.

like image 192
skaffman Avatar answered Dec 26 '22 16:12

skaffman


This might be a little too old, but I just managed to get javamail and sendmail to work together. It's actually super easy and I felt stupid for not getting it done faster...

Let's ignore sendmail for a bit here. How can we send an e-mail through javamail? There are tons of tutorials online, but here's how it's done:

  1. Create your session with the appropriate authenticator;
  2. Create your MimeMessage object (here's where you add all your recipient addresses);
  3. Call Transport.send() with your message.

What if your SMTP server only sends emails up to 100 recipients (like mine)? That's when sendmail comes into play. You can think about sendmail as your own SMTP server. So install it first. If you're running Ubuntu (like me), just do:

sudo apt-get install sendmail

The installation ends pretty quickly. After that, sendmail is ready to be used. I didn't bother configuring any type of authentication or whatsoever, but it's probably a good idea to do so if your server will have a public IP on the internet. Now, instead of pointing your java code (that uses javamail) to your SMTP server, just point it to localhost (or whatever machine you just installed sendmail).

You can even test your sendmail installation with your regular mail client (thunderbird, outlook, windows mail or whatever floats your boat). Just configure your SMTP server to the machine you installed sendmail. Guess what? It works!

Just don't use this to send emails to the entire world... ;)

like image 28
Andre Avatar answered Dec 26 '22 17:12

Andre