0

I am using JavaMail along with Postfix on an Ubuntu mail server. My desire is to send emails very rapidly for a newsletter with millions of recipients. So far, we are only able to get a performance of at most about 7 emails per second. I know there are several questions of this type on here already, so I've compiled some of the suggestions that I've found:

  • Use multi-threading. With this, I have the concern of flooding Postfix with too many incoming messages. Does anyone have any experience with the scalability of this?
  • Use Transport.send(Message msg, Address[] addresses) to send to multiple recipients at once. Does anyone know how this solution differs from just adding multiple recipients via BCC? Does it send to each address individually, or one message addressed to multiple recipients?
  • Use only one Session object for all messages. This one seems to make sense, and can probably be used along with points 1 and 2.

My overarching question is also whether I'm missing any points above, or if anyone has any experiences they can share with using JavaMail to build a bulk mail delivery system.

John Roberts
  • 5,885
  • 21
  • 70
  • 124
  • 3
    Sending mail to millions of recipients is a good way to get your connection blacklisted for spamming, I suspect. Are you sure the problem is in JavaMail and not, say, in [Postfix settings](http://serverfault.com/q/290684/173836)? – Ken Y-N Dec 07 '15 at 02:42
  • Possible duplicate of [javamail vs sendmail performance during bulk email](http://stackoverflow.com/questions/1780112/javamail-vs-sendmail-performance-during-bulk-email) – Ken Y-N Dec 07 '15 at 02:47
  • Or the server rate-limiting you? JavaMail isn't inefficient. – user207421 Dec 07 '15 at 02:47
  • @KenY-N These are legitimate subscribers. Whether that matters to ISPs or not is a different story, I suppose. It's possible that there's a Postfix setting I need to tweak. However, my goal was to try to maximize JavaMail first. – John Roberts Dec 07 '15 at 02:51
  • Are you using a single Transport and a single connection to send all copies of the message? What performance work have you done already to determine where the source of the problem is? – Bill Shannon Dec 07 '15 at 04:24
  • @BillShannon Honor to have the creator/maintainer to consult with. I am using the same session for each email. The reason for this is because I set the "mail.smtp.from" dynamically for each email I send. I'm a little confused by what you mean by "using a single Transport". I am using Transport statically, with the Transport.send method. Could you please elaborate? – John Roberts Dec 08 '15 at 02:00
  • Have you seen the [JavaMail FAQ](http://www.oracle.com/technetwork/java/javamail/faq/index.html#rptsend)? – Bill Shannon Dec 08 '15 at 03:50
  • @BillShannon I had read part of it, but not that part. Thank you. Could you also please tell me what is the difference between using the send(Address []) method to send to multiple recipients, and just adding multiple recipients as part of the "To" property? – John Roberts Dec 08 '15 at 04:08
  • The method that takes Addresses allows you to send the message to addresses not in the header, e.g., for Bcc, or to send a newsletter to a bunch of people without exposing the email addresses of all the recipients. – Bill Shannon Dec 08 '15 at 05:46
  • @BillShannon So in effect, it is the same as setting a bunch of BCC recipients? – John Roberts Dec 08 '15 at 12:19
  • Yes, but with more control. You can also send the message to fewer addresses than are listed in the headers. It's a lower level of control; Bcc handles the common cases. – Bill Shannon Dec 08 '15 at 22:12

0 Answers0