Solved

Sendmail/Slackware .forward .deliver options

Posted on 1997-12-10
3
278 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
ID: 1634565
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
ID: 1634566
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
ID: 1634567
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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

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 …
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.
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.

776 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