Solved

Sendmail/Slackware .forward .deliver options

Posted on 1997-12-10
3
283 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 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

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

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

Suggested Solutions

SSH (Secure Shell) - Tips and Tricks As you all know SSH(Secure Shell) is a network protocol, which we use to access/transfer files securely between two networked devices. SSH was actually designed as a replacement for insecure protocols that sen…
1. Introduction As many people are interested in Linux but not as many are interested or knowledgeable (enough) to install Linux on their system, here is a safe way to try out Linux on your existing (Windows) system. The idea is that you insta…
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.

733 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