Solved

Sendmail/Slackware .forward .deliver options

Posted on 1997-12-10
3
272 Views
Last Modified: 2013-12-05
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
Comment
Question by:posko
  • 2
3 Comments
 
LVL 1

Expert Comment

by:dagmar
Comment Utility
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
 

Author Comment

by:posko
Comment Utility
This is also useful information but can it do the same with all incoming messages (*@*.*), not just a specified e-mail address?

0
 
LVL 1

Accepted Solution

by:
dagmar earned 100 total points
Comment Utility
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Linux users are sometimes dumbfounded by the severe lack of documentation on a topic. Sometimes, the documentation is copious, but other times, you end up with some obscure "it varies depending on your distribution" over and over when searching for …
Join Greg Farro and Ethan Banks from Packet Pushers (http://packetpushers.net/podcast/podcasts/pq-show-93-smart-network-monitoring-paessler-sponsored/) and Greg Ross from Paessler (https://www.paessler.com/prtg) for a discussion about smart network …
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now