Hi, i wrote a mailet thats split the email in single emails per recipient. But sometimes i get this error for example:
We were unable to deliver the attached message because of an error in the mail server. Message details: Subject: FAILED: AS29562 Sent date: Fri Mar 10 06:51:48 CET 2006 MAIL FROM: null RCPT TO: [EMAIL PROTECTED] From: RIPE Database Administration <[EMAIL PROTECTED]> To: [EMAIL PROTECTED] Size (in bytes): 2044 In the deadletter table is nothing usefull insert.. Anyone can give me a hint whats the problem ? I attached the mailet. bye
package org.apache.james.transport.mailets; import org.apache.mailet.GenericMailet; import org.apache.mailet.Mail; import org.apache.mailet.MailAddress; import javax.mail.MessagingException; import javax.mail.internet.MimeMessage; import java.util.Arrays; import java.util.Collection; import java.util.Iterator; /** * Split the email for each recipient and pass it to a processor so we can process it later for each recip. * This make it possible to use diffrent settings for each recip. * * Set the follow headers: * X-Domain: domain.de * X-User: [EMAIL PROTECTED] * * <br><br> * * Sample Configuration: * <br><br> * <mailet match="All" class="SplitEmail"> * <processor>sender</processor> * </mailet> * <br><br> * @author Norman Maurer <[EMAIL PROTECTED]> */ public class SplitEmail extends GenericMailet { protected String domain = null; protected String user = null; protected String excubatorState = "sender"; private final String HEADER_USER = "X-User"; private final String HEADER_DOMAIN = "X-Domain"; public void init() throws MessagingException { String excubatorState = getInitParameter("processor"); if (excubatorState == null || excubatorState.equals("")) { excubatorState = "sender"; } } /** * split the email * * @param mail the mail being processed * * @throws MessagingException if an error occurs while splitting the mail */ public void service(Mail mail) throws MessagingException { Collection recipients = mail.getRecipients(); for (Iterator i = recipients.iterator(); i.hasNext();) { Mail newMail = mail; MimeMessage message = newMail.getMessage(); MailAddress recipient = (MailAddress) i.next(); MailAddress sender = newMail.getSender(); user = recipient.toString().toLowerCase(); domain = recipient.getHost().toString().toLowerCase(); /* * Set the right user for later using */ message.setHeader(HEADER_USER, user); message.setHeader(HEADER_DOMAIN, domain); message.saveChanges(); try { getMailetContext().sendMail(sender, Arrays.asList(new MailAddress[] { recipient }), message, excubatorState); log("sender: " + sender + " | " + "recipient: " + user); } catch (MessagingException ex) { log("Error while splitting mail.", ex); } } /* * drop the orginal mail */ mail.setState(Mail.GHOST); } /** * Return a string describing this mailet. * * @return a string describing this mailet */ public String getMailetInfo() { return "SplitEmail Mailet"; } }
signature.asc
Description: Dies ist ein digital signierter Nachrichtenteil