views:

1211

answers:

3

Hi all,

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

+4  A: 

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.

skaffman
+1  A: 

First of all, I suppose this is for legitimate reasons and not spamming?

Sendmail is very, very fast for sending emails. What is not so fast is the DNS lookups needed to locate the mailservers for the domain - you need to do a MX query for each - and that would fit fine with the 5 messages pr second you report.

When that is said, you would probably be best off with standard high-performance mailing list software where you construct the message with javamail and tell the mailing list software to send it to everybody. Also ally with e.g. Google Mail as they scale well, to actually get them all sent. Google Apps for Java can allow you to send from within the Google cloud.

Back in ancient history when I worked with that Majordomo worked fine with sendmail. ezmlm works well with qmail (but is probably abandoned by now) and I think mjmlm works well with postfix.

Thorbjørn Ravn Andersen
Yes it is for legit reasons. Institution sending emails to employees with a customised pdf attachment. The attachment and recipient details comes from an Oracle database, so Google Apps integration isn't possible. (shame as we have a partnership with Google).
Glenn2041
A: 

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... ;)

Andre