classpathx-javamail
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Classpathx-javamail] Re: Bug: duplicate message ids


From: Boris Folgmann
Subject: [Classpathx-javamail] Re: Bug: duplicate message ids
Date: Thu, 26 Apr 2007 14:55:50 +0200
User-agent: Mozilla/5.0 (X11; U; Linux i686; de-AT; rv:1.8.0.10) Gecko/20070226 MultiZilla/1.8.3.0a SeaMonkey/1.0.8

Hi,

Chris Burdess schrieb/wrote:
to create and send the messages? You're not reusing MimeMessage object instances?

Yes, log4j does it! msg is a member variable of SMTPAppender.
They initialize it once when the log4j user calls activateOptions() which has to be done after setting all options on the appender but before starting to log. See source below.

Our webapp also sends mail by itself, but doesn't reuse the MimeMessage objects. Our message ids are unique, so your guess was right! Our code is old, but IIRC think we've chosen to use local MimeMessage objects so that the application scales well, since it's multi-threaded. But is there also a restriction in the JavaMail specification, that is violated by log4j by reusing the MimeMessage object?

If not, I suppose that Transport.send() should set the message id on each call.

Here's their code:

  /**
     Activate the specified options, such as the smtp host, the
     recipient, from, etc. */
  public
  void activateOptions() {
    Properties props = new Properties (System.getProperties());
    if (smtpHost != null)
      props.put("mail.smtp.host", smtpHost);


    Session session = Session.getInstance(props, null);
    //session.setDebug(true);
    msg = new MimeMessage(session);

     try {
       if (from != null)
         msg.setFrom(getAddress(from));
       else
         msg.setFrom();

       msg.setRecipients(Message.RecipientType.TO, parseAddress(to));
       if(subject != null)
         msg.setSubject(subject);
     } catch(MessagingException e) {
       LogLog.error("Could not activate SMTPAppender options.", e );
     }
  }

cu,
        boris





reply via email to

[Prev in Thread] Current Thread [Next in Thread]