/** * init will setup static values for sender, recipients, message text, and reply to *
if isStatic() returns true * it calls getSender(), getReplyTo(), getMessage(), and getRecipients() and getTo() * */ public void init() throws MessagingException { log("redirect init"); if(isStatic()){ sender = getSender()==null ? getMailetContext().getPostmaster():getSender(); replyTo = getReplyTo()==null ? getMailetContext().getPostmaster():getReplyTo(); messageText = getMessage(); recipients = getRecipients(sender);//CHANGED (if static, then normally you put an address in the config.xml - here "sender" is // just a "DUMMY") apparentlyTo = getTo(); log("static, sender="+sender+", replyTo="+replyTo+", message="+messageText+" "); } } /** * * Service does the hard work,and redirects the mail in the form specified * * */ public void service(Mail mail) throws MessagingException { if(!isStatic()){ sender = getSender(); replyTo = getReplyTo(); messageText = getMessage(); recipients = getRecipients(mail.getSender()); //CHANGED!!!!!!!!!!!! apparentlyTo = getTo(); log("dynamic, sender="+sender+", recipients="+recipients+" ,message="+messageText+" "); } .... continue at 'getRecipients(MailAddress mailAddr) public Collection getRecipients(MailAddress mailAddr){ Collection newRecipients = new HashSet(); String addressList = getInitParameter("recipients")==null? getInitParameter("to"):getInitParameter("recipients"); // I put 'senderAddress' in the config.xml at (just take a word you prefer) // So, if it equals then take the Senderaddress and add it to if(addressList.equals("senderAddress")) { newRecipients.add(mailAddr); } else { StringTokenizer st = new StringTokenizer(addressList, ",", false); while (st.hasMoreTokens()) { try{ newRecipients.add(new MailAddress(st.nextToken())); }catch(Exception e){ log("add recipient failed in getRecipients"); } } } return newRecipients; } of course i had to change getTo() too: since I donīt use the -Tag the config.xml, I didnīt made much changes as you can see below! public InternetAddress[] getTo(){ InternetAddress[] iaarray = null; String addressList = getInitParameter("to")==null? getInitParameter("recipients"):getInitParameter("to"); if(addressList == null) { return iaarray; } else { StringTokenizer rec = new StringTokenizer(addressList,",") ; int tokensn = rec.countTokens(); iaarray = new InternetAddress[tokensn]; String tokenx =""; for( int i=0;i