You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-user@james.apache.org by Benjamin Yeo <ro...@gmail.com> on 2016/05/16 17:30:43 UTC

Am I able to get the information of the mail sender and receiver?

package org.apache.james.transport.matchers;

import java.io.*;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Collection;
import java.util.HashSet;
import java.util.Properties;

import javax.mail.*;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;

import org.apache.mailet.GenericMatcher;
import org.apache.mailet.Mail;
import org.apache.mailet.MailAddress;

import java.lang.Class;
public class SenderIsGreyList
  extends GenericMatcher
{

  private Collection senders;

public void init()
    throws MessagingException
  {

//I want to be able to get the information of the mail here.. how do I do
it?
I want to know the email sender address, email receiver address and then
store it in a collection like senders and match it below.

I tried to leave everything here empty and went below and I was able to use
mail.getSender() and getReceiver to do the matching. How do I do it here so
that it can match properly below?

  }

  public Collection match(Mail mail)
  {
if (this.senders.contains(mail.getSender())) {
      return mail.getRecipients();
    } else {
    return null;
    }
  }
}