james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Stefano Bagnara (JIRA)" <server-...@james.apache.org>
Subject [jira] Commented: (JAMES-444) Add support for "Expires" header in remotedelivery
Date Wed, 22 Feb 2006 20:54:38 GMT
    [ http://issues.apache.org/jira/browse/JAMES-444?page=comments#action_12367410 ] 

Stefano Bagnara commented on JAMES-444:
---------------------------------------

Here is the comment from Marcel Ruff:
--------------------------------

if have added following code snippet to
 src/java/org/apache/james/transport/mailets/RemoteDelivery.java
method
 private boolean deliver(MailImpl mail, Session session) :

---------------------------------------------------------------------------------------
HostAddress outgoingMailServer = (HostAddress) targetServers.next(); // <--- Existing line
//====== Expires patch start
try {
    //
    // Expiry Date Indication
    // Supported as new RFC 822 header (Expires:).
    // @see http://www.faqs.org/rfcs/rfc2156.html
    // @see james/logs/mailet-*.log
    //
   final String EXPIRES_HEADER_RFC2156 = "Expires";
   String[] expires = mail.getMessage().getHeader(EXPIRES_HEADER_RFC2156);
   if (expires != null && expires.length > 0) {
      // Date: Thu, 17 Nov 2005 16:45:12 +0100 (CET)
      String value = expires[0].trim();
      java.text.DateFormat df = new javax.mail.internet.MailDateFormat();
      java.util.Date expire = df.parse(value);
      java.util.Date now = new java.util.Date();
      if (now.getTime() > expire.getTime()) {
          StringBuffer logMessageBuffer =
            new StringBuffer(256)
            .append("Mail ")
            .append(mail.getName())
            .append(" to host ")
            .append(outgoingMailServer.getHostName())
            .append(" at ")
            .append(outgoingMailServer.getHost())
            .append(" to addresses ")
            .append(Arrays.asList(addr))
            .append(" is expired since ")
            .append(value)
            .append(" and is discarded");
         log(logMessageBuffer.toString());
         return true;
      }
   }
}
catch (Throwable e) {
   e.printStackTrace(); // Ignore Expires: problems
}
//====== Expires patch end
StringBuffer logMessageBuffer = ...  // <--- Existing line
---------------------------------------------------

now expired mails are nicely discarded.

This header is well established for 'news' (RFC1036) and
specified in RFC2156 for X.400 -> RCF822(email) gateways as an optional header.
(In the predecessor document RFC1327 it was called "Expiry-Date:" but changed later to "Expires:")
This is tested with james 2.2.0 and should work fine
with the current svn code as well.

Is it possible to add this to james as a new feature?

thanks 

> Add support for "Expires" header in remotedelivery
> --------------------------------------------------
>
>          Key: JAMES-444
>          URL: http://issues.apache.org/jira/browse/JAMES-444
>      Project: James
>         Type: Improvement
>   Components: Matchers/Mailets (bundled)
>     Versions: 2.3.0a1
>     Reporter: Stefano Bagnara
>     Assignee: Stefano Bagnara
>     Priority: Minor

>
> Every of our emails has a
> Expires: Thu, 15 Dec 2005 21:45:01 +0100 (CET)
> header (new RFC 822 'Expires:' header and http://www.faqs.org/rfcs/rfc2156.html).
> If the follow-up MTA is down for say one day all mails
> are hold by james in its outgoing queue.
> As most of our mails expire after one minute there
> may be say 20000 mails which are expired during a day.
> I don't want to forward them when the folloup MTA comes
> up again but just silently erase them.
> I think the mailet interface is invoked when the mail
> arrives to james (and is not expired at this point)
> but not when james tries to forward them - true?
> thanks for some insight,
> Marcel 

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


Mime
View raw message