I'm trying to gather a copy all the mail that goes through my sendmail into a named pipees so I can gather statistics and what not.
I believe a copy of all mail is stored in var/spool/mail?
I tried to replace the mail directory with a named pipe and that messed sendmail up; I'm not sure how sendmail is working b/c there is no record of a mail log anymore.
Anyways, to fix this I tried setting up a .forward file in my home directory with:
/var/spool/mail/eric (i remade the mail directory and gave it write permission; eric is the name of my named pipe)
This isn't working. I'm a noob.
ANY advice would be appreciated. I've been trying to fix this for two days and I can't even get a lead.
Thanks! and let me know how confusing this post was.
You could try forwarding mail to procmail which is a mail filter to make a copy of the mail while the original goes to it's mailbox so you might not get trouble with sendmail cause you don't alter the type of the mail box file. Not sure if it works and procmail get's stuck but maybe worth a try. If it doesn't work, you might want to think about an alternative way like using a special user for those mails and/or using aliases etc.
We use a mechanism like that to split a mail and forward it filtered to different recipients and tools etc. for further processing (in this case munpack, a mime decoder to separate the message from the attachment).
You will need to write a small recipe for procmail which is not hard - there are plenty of How-Tos etc. (Procmail How-To Page).
Here an example:
Push it to procmail:
$> cat .forward
"|/usr/bin/procmail -f-"
Here is the filter setup:
:0 is the original, :0c are copies...; From and Subject are used as filter; ! in front of the email address means to forward a copy to that user. The pipe hands a copy over to munpack.
$> cat .procmailrc
MAILDIR=$HOME/in
LOGFILE=$HOME/log/incomming.`date +%y-%m-%d`
:0
* ^From.*thisguy@somedom.com
* ^Subject:.*Here comes your latest data
{
:0c
! another.guy@mydom.com
:0
| /usr/local/bin/munpack
}
:0
* ^From.*
/some/tmp/dir
---------- Post updated at 10:03 AM ---------- Previous update was at 10:02 AM ----------
I'm not sure. I'm helping out a fellow superior of mine.
---------- Post updated at 10:59 AM ---------- Previous update was at 10:03 AM ----------
Ok the procmail file is what I need.
I'm running Ubuntu Server 9.1
and sendmail 8.14.3
I have 3 questions about the .procmailrc on my system
1) where is it on my system?
2) do I need to invoke sendmail from the sendmail.mc file?
3) you use a .forward file to invoke sendmail; where should my .forward file be located?
---------- Post updated at 02:49 PM ---------- Previous update was at 10:59 AM ----------
which procmail
# if it does not return anything do
dpkg -l procmail| grep ^ii
If both does not return anything, you will have to install it. I guess Ubuntu uses apt or something like Debian. In that case:
apt-get install procmail
sendmail should be up and running - check for it's process with ps.
Both .procmailrc and .forward have to be placed in the home directory of the user you are using.
Edit:
In case this named pipe stuff will still not work, you might want to explain us a bit more in detail, what you are going to do so we can suggest maybe a more appropriate solution.