commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Hao Zheng (JIRA)" <>
Subject [jira] Created: (EMAIL-72) sending several emails in a batch
Date Thu, 21 Feb 2008 05:16:43 GMT
sending several emails in a batch

                 Key: EMAIL-72
             Project: Commons Email
          Issue Type: New Feature
         Environment: any
            Reporter: Hao Zheng

I found when i want to send several emails in one connection, Commons Email doesn't help.
It connects to the SMTP server per email, and it spends more time on connecting and authentication
than sending the mails themselve (most SMTP server needs authentication). So I have to code
on the javamail api directly, something like:

        SMTPSSLTransport strans = (SMTPSSLTransport) sess.getTransport();
        int num = 1000;
        for (int i = 0; i < num; i++) {
            SMTPMessage email = createMessage(sess, num);
            strans.sendMessage(email, email.getAllRecipients());

In my straightforward test, it saves me 2/3 of the time. So I think it would be nice to add
this kind of function into Commons Email, to make it more useful.

My suggestion is to extract a cleaner Email bean, which contains all email dependent information,
e.g. TO, CC, Subject, etc, but leaves out all host/server dependent information, e.g. authenticator,
host address, host port, etc. After that, we can still provide simple convenience method for
those who only want to send one mail every time. And it is possible to add methods like 'addEmail'
to add several mails before sending, and later on, when it is called 'send', we can send them
in one SMTP connection. It's much like the API of javamail itself, but we can provide more
convenient usage than it. Code will look like this:

 EmailTransmission trans = new EmailTransmission();

 HtmlEmail email1 = new HtmlEmail();
 HtmlEmail email2 = new HtmlEmail();


This message is automatically generated by JIRA.
You can reply to this email to add a comment to the issue online.

View raw message