Hi Corey,
Try compiling this:
package com.intelekia.mailets;
import java.util.Collection;
import java.util.HashSet;
import javax.mail.MessagingException;
import org.apache.james.core.MailImpl;
import org.apache.james.services.MailServer;
import org.apache.mailet.GenericMailet;
import org.apache.mailet.Mail;
import org.apache.mailet.MailAddress;
public class CopyMessage extends GenericMailet {
Collection recipients = new HashSet(1);
String processor = null;
MailServer server = null;
boolean canServe = false;
private static long count;
public void init() throws MessagingException {
try {
recipients.add(new MailAddress(getInitParameter("recipient")));
processor = getInitParameter("processor");
server = (MailServer) this.getMailetContext();
if (processor != null && server != null) {
canServe = true;
}
} catch (Exception e) {
e.printStackTrace();
}
}
public void service(Mail mail) throws MessagingException {
if (canServe) {
MailImpl mailImpl = (MailImpl) mail;
MailImpl copyMail = (MailImpl) mailImpl.duplicate(getId());
copyMail.setRecipients(recipients);
copyMail.setState(processor);
server.sendMail(copyMail);
}
}
public String getMailetInfo() {
return "CopyMessage Mailet";
}
private static String getId() {
long localCount = -1;
synchronized (CopyMessage.class) {
localCount = count++;
}
StringBuffer idBuffer =
new StringBuffer(64)
.append("Mail")
.append(System.currentTimeMillis())
.append("-")
.append(localCount);
return idBuffer.toString();
}
}
Then call it from your config.xml file like this:
<spoolmanager>
<!-- Number of spool threads -->
<threads> 10 </threads>
<!-- Set the Java packages from which to load mailets and matchers -->
<mailetpackages>
<mailetpackage>org.apache.james.transport.mailets</mailetpackage>
<mailetpackage>com.intelekia.mailets</mailetpackage>
</mailetpackages>
<matcherpackages>
<matcherpackage>org.apache.james.transport.matchers</matcherpackage>
</matcherpackages>
<!-- The root processor is a required processor - Envoy routes all
mail on the spool -->
<!-- through this processor first. -->
<!-- -->
<!-- This configuration is a sample configuration for the root
processor. -->
<processor name="root">
<!-- Important check to avoid looping -->
<mailet match="RelayLimit=30" class="Null"/>
<mailet match="All" class="CopyMessage">
<recipient> [EMAIL PROTECTED] </recipient>
<processor> transport </processor>
</mailet>
[... ETC ...]
That's it, quite self-explanatory I guess.
"And i think it
would be good if i can have it ignore (not copy) any postmaster emails.."
I think you can easily do it yourself by playing with the
org.apache.james.transport.matchers SenderIs & RecipientIs (or quickly
creating a boolean counterpart SenderIsNot & RecipientIsNot), like:
<mailet match="[EMAIL PROTECTED]"
class="CopyMessage">
<recipient> [EMAIL PROTECTED] </recipient>
<processor> transport </processor>
</mailet>
Hope this helps,
Isaac.
-----Original Message-----
From: Corey A. Johnson [mailto:[EMAIL PROTECTED]
Sent: mi�rcoles, 03 de noviembre de 2004 0:01
To: James Users List
Subject: copy account
Hello All,
Was hoping someone could point me in the right direction. Is their an
existing mailet/matcher that would allow for the configuration of a copy
account? I have a client that i installed James for.. has been working
great.. now they have asked me to setup a "copy account." Basically
they want a copy of any email sent or received via their James server to
be sent to a specific mailbox (on the James server). And i think it
would be good if i can have it ignore (not copy) any postmaster emails..
Hoping something exists already. I looked through the mailets and
matchers.. it seems some may exist that could be used. But i am not
100% sure.
very sorry if their is an obvious solution. i searched the through the
mail list archives.. could not find an exact solution.
thanks in advance for any advise or nudges!
Cj
--
Corey A. Johnson
Creative Network Innovations
http://www.cniweb.net/
1-800-CNi-5547 ** 1-321-259-1984
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]