[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[cobalt-users] RE: Email Forwarding with Copy (LONG)



> Can someone tell me how to forward e-mail to another
> address, leaving a
> copy in the originating mailbox in a Raq3 server ? Up till
> now I can enable
> forwarding without leaving copies of the messages.

Well, I'm not someone who normally barks back saying; "This has been
discussed numerous times, check the archives"...BUT...<laugh> it *was*
discussed only yesterday! The context was slightly different, but the
answer interestingly enough is the same.
You need procmail. Procmail rocks.
What you don't specify is if you want mail for a specific user
forwarded, mail for an entire domain forwarded? Lots depend on exactly
what you want and how you want it done.

If you're asking for mail on a per user basis to be dumped into the user
maildir with a copy to be sent elsewhere, this could be done via the
user's .procmailrc in their home directory, or if users don't have shell
access, via the global /etc/procmailrc (note the absence of the leading
dot!)

So, the following accomplishes this objective in either the local or
global file;
-------------------<cut below this line>-----------
  :0:
* ^TO_user@xxxxxxxxxxxxxx
{
	0c
	! user@xxxxxxxxxxxxxxxxxxxxx
}
-------------------<end cut here>------------------
If however, you are seeking to accomplish the same for an entire domain,
the following would accomplish *that* objective:

(Exerpted from yesterday's conversation on the same or similar subject):
-------------------<cut below this line>-----------
#Catches all mail and stuffs a *carbon-copy*
#of the mail into the siteadmin's maildir
#leaves the mail in the spool to be grabbed
#by _some_ external mail server via _some_
#retrieval method
#
#uses a lockfile to prevent a bigmess (tm)
#if several procmail processes are concurrently
#writing to the maildir
#
#use of the TO_ macro catches Cc's as well as
#mail sent directly to the domain
#
#to deploy:
#Right after the macro underscore (* ^TO_) substitute your domain_name
#_without a space between the underscore and the domain name_
#
#note that the mailpath is ficticious of course
#a figment of the imagination
#adjust to suit your environment

  :0c :
 * ^TO_.+[@.]customer_domain\.tld
  /home/sites/site69/users/site_admin_dude/mail
----------------------------<end cut here>-----------------

This doesn't even scratch the surface of what procmail *can* do.
However, the following might be useful further reading:
man procmailrc, man procmailex, man procmailsc

If you hate staring at a monochrome man page, try procmail's man pages
in html.(they still need to be read carefully however <laugh>) Pay
particular attention to man procmailex, there are examples in there that
apply to almost all procmail mail filters. These man pages can be seen
at:
http://www.voicenet.com/~dfma/intro.html

Nancy McGough's Procmail "Quick Start" page always heads the list of
resources "beyond the man page" at:
http://www.ii.com/internet/robots/procmail/qs/

For some useful examples beyond man procmailex(5) try Timo Salmi's
procmail tips page. Timo's a very nice guy as well as being a talented
mathematician, most of his stuff is useful to beginners and advanced
users alike.
http://www.uwasa.fi/~ts/info/proctips.html

Close to last (but certainly not least) is John Hardin's ultimate email
sanitizer. Beware!!! This is the *last* thing you should do, not the
first. It is not for the faint of heart or a beginner.
http://www.impsec.org/email-tools/procmail-security.html

Further resources (of course) can be found at:
http://www.procmail.org/

Hope This Helps!
Regards,
-Colin
--
Colin J. Raven