title: SES Boost Mail Speed
body: <p>I am using SES and trying to send emails to almost 2000 people at one go. The code which I am using is written in JAVA using javamail library and it takes around 28 seconds to deliver 22 mails. </p>
  
  <p>Is there any way I can boost the speed up by changing language or library or any alternate way. Here is my code for reference, I am already using threads:</p>
  
  <pre><code>import java.util.ArrayList;
  import java.util.Date;
  import java.util.Properties;
  
  import javax.mail.Message;
  import javax.mail.MessagingException;
  import javax.mail.Session;
  import javax.mail.Transport;
  import javax.mail.internet.InternetAddress;
  import javax.mail.internet.MimeMessage;
  
  public class AmazonSESSample implements Runnable {
      private String to = "";
      public static Properties props = System.getProperties();
      public static Session session = Session.getDefaultInstance(props);
  
      static final String FROM = "info@domain.com";
      static final String BODY = "This email was sent through the Amazon SES SMTP interface by using Java.";
      static final String SUBJECT = "Amazon SES test (SMTP interface accessed using Java)";
      static final String SMTP_USERNAME = "username";
      static final String SMTP_PASSWORD = "password";
      static final String HOST = "ses_host";
      static final int PORT = 000;
  
      public static Transport transport;
  
      @Override
      public void run() {
          try {
              this.sendMail();
          } catch (MessagingException e) {
              e.printStackTrace();
          }
      }
  
      public void setParameters(String to) {
          this.to = to;
      }
  
      private void sendMail() throws MessagingException {
          MimeMessage msg = new MimeMessage(session);
          msg.setFrom(new InternetAddress(FROM));
          msg.setRecipients(Message.RecipientType.TO, to);
          msg.setSubject(SUBJECT);
          msg.setContent(BODY, "text/plain");
          try {
              System.out.println("Attempting to send an email through the Amazon SES SMTP interface...");
              msg.saveChanges();
              transport.sendMessage(msg, msg.getAllRecipients());
              Date date = new Date();
              System.out.println("Email sent!" + date.toString());
          } catch (Exception ex) {
              System.out.println("The email was not sent.");
              System.out.println("Error message: " + ex.getMessage());
          }
      }
  
      public static void main(String[] args) throws MessagingException {
          props.put("mail.transport.protocol", "smtp");
          props.put("mail.smtp.port", PORT);
          props.put("mail.smtp.auth", "true");
          props.put("mail.smtp.starttls.enable", "true");
          props.put("mail.smtp.starttls.required", "true");
          ArrayList&lt;String&gt; emails = new ArrayList&lt;String&gt;(); // String list of emails
          transport = session.getTransport();
          transport.connect(HOST, SMTP_USERNAME, SMTP_PASSWORD);
          Date date = new Date();
          System.out.println(date.toString());
  
          for (int i = 0; i &lt; emails.size(); i++) {
              AmazonSESSample sendmail = new AmazonSESSample();
              sendmail.setParameters(emails.get(i).toString());
              Thread t = new Thread(sendmail);
              t.start();
          }
          // transport.close();
      }
  
  }
  </code></pre>