?
Solved

Sendmail/Slackware .forward .deliver options

Posted on 1997-12-10
3
Medium Priority
?
292 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 200 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

10 Questions to Ask when Buying Backup Software

Choosing the right backup solution for your organization can be a daunting task. To make the selection process easier, ask solution providers these 10 key questions.

Question has a verified solution.

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

It’s 2016. Password authentication should be dead — or at least close to dying. But, unfortunately, it has not traversed Quagga stage yet. Using password authentication is like laundering hotel guest linens with a washboard — it’s Passé.
In the first part of this tutorial we will cover the prerequisites for installing SQL Server vNext on Linux.
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.
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.
Suggested Courses
Course of the Month12 days, 2 hours left to enroll

752 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