You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by "Noel J. Bergman" <no...@devtech.com> on 2002/06/09 03:11:04 UTC

Mailet API and Getting Relays from Message

Does anyone have a better regex than

  (from|FROM)
.*[\\(\\[]([0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3})[\\]\\)]

for stripping the IP address from a Received header?

Basically, I've code that does:

   String[] relays = message.getHeader("Received");

   for (int i = 0; i < relays.length; i++)
     if (matcher.contains(relays[i], pattern))
     {
        String ip = matcher.getMatch().group(2));
        ...
     }

It works with all of the headers I have come across so far, but I'm just
checking.

Since I already have several matchers that want this information, I'm
thinking of making this a utility method, e.g.,

	public String[] getRelays(MimeMessage);

Alternatively, a natural place to hang this would be on
org.apache.mailet.Mail as

	public String[] getRelays();

but I am not going to change that interface without agreement!

	--- Noel


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>