Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 301
  • Last Modified:

Sendmail/Slackware .forward .deliver options

I want to be able to leave a copy of a mail message in the intended mail box but also forward a copy to 2 or 3 other accounts.
0
posko
Asked:
posko
  • 2
1 Solution
 
dagmarCommented:
I'm not so sure that you should be using .forwards to do this, nor should you try and use /etc/aliases.  Both mechanisms can quickly lend themselves to some really evil looping of mail, which coupled with a mailing list somewhere, could become rather nightmarish in a very short time indeed.  (Mail comes in for bob, is delivered to bob, alice, and eve.  Mail for bob is delivered to bob, alice, and eve.  Mail for bob... you get the picture.)  Neither of these mechanisms have any clean method for detecting loops.

You should probably just use procmail for this purpose.  Procmail fits itself into the loop WITHOUT the unneccessary risk of sending the email back through the MTA (sendmail).  Just about every version of Slackware from 3.0 (I think, I started using it at 3.1) onwards has this as a part of the distribution.

Slightly mangled from the 'man procmailex' page, the following fragment will send any email coming from friend@public.com to inic@nevwest.com as well as back to Wallace Spamford, and file a copy of it in your 'spam' folder...

-----8<-----
PATH=/bin:/usr/bin:/usr/local/bin
MAILDIR=$HOME/mail
LOGFILE=$HOME/.procmail.log

:0 Wh: msgid.lock
| formail -D 8192 msgid.cache

:0:
* ^From.*friend@public.com
{
  :0 c
  ! inic@nevwest.com
  ! root@cyberpromo.com

  :0
  spam
}
-----8<-----

That bit in the middle about msgid.cache is something which will automatically trash messages with duplicate message-IDs (i.e., email that just came in a few minutes ago, and has somehow been duplicated somewhere.)

There is an example of how to make a backup folder to hold backups of the last (n) messages, as well as a number of other nifty tricks which you can do with procmail.  Furthermore, probably the easiest way to determine if you have procmail installed already is to simply plonk the first three lines of that cut file into a ~/.procmailrc file, and send yourself some mail.  If you have it installed, the ~/.procmail.log file will magically appear.  :)   Good luck!
0
 
poskoAuthor Commented:
This is also useful information but can it do the same with all incoming messages (*@*.*), not just a specified e-mail address?

0
 
dagmarCommented:
Oh yeah, of course.  Using...

* ^TO.*

Should wildcard match just about anything and everything...
(Well, everything with at least one character in the To: or CC: fields, to be specific.)
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now