1 17 18 package org.apache.james.transport.matchers; 19 20 import org.apache.mailet.GenericMatcher; 21 import org.apache.mailet.Mail; 22 23 import javax.mail.MessagingException ; 24 import java.net.InetAddress ; 25 import java.net.UnknownHostException ; 26 import java.util.Collection ; 27 import java.util.StringTokenizer ; 28 29 44 public class InSpammerBlacklist extends GenericMatcher { 45 String network = null; 46 47 public void init() throws MessagingException { 48 network = getCondition(); 49 } 50 51 public Collection match(Mail mail) { 52 String host = mail.getRemoteAddr(); 53 try { 54 StringBuffer sb = new StringBuffer (); 56 StringTokenizer st = new StringTokenizer (host, " .", false); 57 58 while (st.hasMoreTokens()) { 59 sb.insert(0, st.nextToken() + "."); 60 } 61 62 sb.append(network); 64 65 org.apache.james.dnsserver.DNSServer.getByName(sb.toString()); 67 68 return mail.getRecipients(); 71 } catch (UnknownHostException uhe) { 72 return null; 74 } 75 } 76 } 77 | Popular Tags |