I'm slowly trying to change my email setup and to test imap/cyrus.
I am changing one server with sendmail that is in the middle of my
internal email stream. What I want (temporarily) is for this server
to detect any email sent to me (mikee(_at_)$DOMAIN(_dot_)com) and hand that
email
to deliver. If the email is not sent to me (mikee(_at_)$DOMAIN(_dot_)com) send
the message to the normail email server (| /usr/lib/sendmail -t).
I briefly put this configuration in place this morning and looking at
a few messages I received it seems like aliases are not being expanded
as the email is being delivered. I'll attach the sendmail.mc, procmailrc,
and one of the messages below. The message to me says a message was
sent to one user three times, that maybe sendmail did not expand and
consolidate aliases before calling procmail. Is there something else I
need to do for this configuration or to allow/force alias expansion?
I am trying to test using IMAP and separating '*** SPAM ***' messages
into distinct folders in IMAP instead of all that junk getting dumped
into a user's INBOX. I replaced my domain with $DOMAIN and the two
user accounts other than mine with $USER1 and $USER2. The account
$USER2 is an alias to $USER1. The variable $USER is a procmail variable.
Mike
------------------- /etc/mail/sendmail.mc
divert(-1)dnl
dnl #
dnl # This is the sendmail macro config file for m4. If you make changes to
dnl # /etc/mail/sendmail.mc, you will need to regenerate the
dnl # /etc/mail/sendmail.cf file by confirming that the sendmail-cf package is
dnl # installed and then performing a
dnl #
dnl # make -C /etc/mail
dnl #
include(`/usr/share/sendmail-cf/m4/cf.m4')dnl
VERSIONID(`setup for Red Hat Linux')dnl
OSTYPE(`linux')dnl
define(`confLOG_LEVEL', `9')dnl
dnl define(`MAIL_HUB', `smtp.$DOMAIN.com')dnl
dnl define(`SMART_HOST', `smtp.$DOMAIN.com')dnl
dnl define(`confFORWARD_PATH', `')dnl
ifdef(`confFROM_HEADER',, `define(`confFROM_HEADER', `<$g>')')
define(`PROCMAIL_MAILER_PATH',`/usr/bin/procmail')dnl
define(`ALIAS_FILE', `/etc/aliases')dnl
define(`STATUS_FILE', `/var/log/mail/statistics')dnl
define(`confDOMAIN_NAME', `$DOMAIN.com')dnl
MASQUERADE_AS(`$DOMAIN.com')dnl
FEATURE(`allmasquerade')dnl
FEATURE(`masquerade_envelope')dnl
FEATURE(`local_procmail')dnl
define(`_DEF_LOCAL_MAILER_FLAGS', `lsADFM5q')
DAEMON_OPTIONS(`Port=smtp, Name=MTA')dnl
MAILER(`procmail')
MAILER(`local')
MAILER(`smtp')
------------------- /etc/mail/sendmail.mc
------------------- /etc/procmailrc
# :!procmail `pwd`/% < #
SHELL=/bin/sh
VERBOSE=on
#USER=$LOGUSER
TO=`formail -X To: | sed 's/^To: *//' | sed 's/^.*[<<]//' | sed 's/[>)].*$//'`
USER=`echo $TO | sed 's/@.*$//'`
DELIVERMAIL="/usr/lib/cyrus-imapd/deliver"
TO=`formail -rtzxFrom:`
#LOGFILE="/var/log/mail/$USER.log"
#LOGFILE=$HOME/procmail/log
IMAP="$DELIVERMAIL -e -a $USER -m user.$USER"
BACKUP="$DELIVERMAIL -e -a $USER -m user.$USER.Backup"
SPAM="$DELIVERMAIL -e -a $USER -m user.$USER.SPAM"
SENDMAIL="/usr/lib/sendmail"
####################################################################
### If the receiver is not mikee(_at_)$DOMAIN(_dot_)com, forward to the mailhost
####################################################################
:0
* !^To: (_dot_)*mikee(_at_)$DOMAIN(_dot_)com(_dot_)*
| $SENDMAIL -t
####################################################################
### Create a backup of the message just in case one of our recipes fail
### We can always comment this out later when we're confident of our recipes
####################################################################
:0Ec
| $BACKUP
####################################################################
### Brain-dead spam filter
####################################################################
:0a
* ^Subject: \*\*\* SPAM \*\*\*.*
| $SPAM
####################################################################
### Deliver it to the user inbox
####################################################################
:0Ew
| $IMAP
:0w
{
EXITCODE=$?
}
------------------- /etc/procmailrc
------------------- message with procmail output
The original message was received at Wed, 31 Jan 2007 06:27:48 -0600
from localhost [127.0.0.1]
----- The following addresses had permanent fatal errors -----
<$USER2(_at_)$DOMAIN(_dot_)com>
(reason: User unknown)
----- Transcript of session follows -----
procmail: [7165] Wed Jan 31 06:27:49 2007
procmail: Executing "formail -X To: | sed 's/^To: *//' | sed 's/^.*[<<]//' |
sed 's/[>)].*$//'"
procmail: [7165] Wed Jan 31 06:27:49 2007
procmail: Assigning "TO=$USER1(_at_)$DOMAIN(_dot_)com"
procmail: Executing "echo $TO | sed 's/@.*$//'"
procmail: Assigning "USER=$USER1"
procmail: Assigning "DELIVERMAIL=/usr/lib/cyrus-imapd/deliver"
procmail: Executing "formail,-rtzxFrom:"
procmail: Assigning "TO="
procmail: Assigning "IMAP=/usr/lib/cyrus-imapd/deliver -e -a $USER1 -m
user.$USER1"
procmail: Assigning "BACKUP=/usr/lib/cyrus-imapd/deliver -e -a $USER1 -m
user.$USER1.Backup"
procmail: Assigning "SPAM=/usr/lib/cyrus-imapd/deliver -e -a $USER1 -m
user.$USER1.SPAM"
procmail: Assigning "SENDMAIL=/usr/lib/sendmail"
procmail: Match on ! "^To: mikee(_at_)$DOMAIN(_dot_)com"
procmail: Executing "/usr/lib/sendmail,-t"
procmail: Assigning "LASTFOLDER=/usr/lib/sendmail -t"
procmail: Notified comsat: "jps@:/usr/lib/sendmail -t"
From root(_at_)$DOMAIN(_dot_)com Wed Jan 31 06:27:49 2007
Subject: *** SPAM *** American General Financial Services $15,000 personal lo
Folder: /usr/lib/sendmail -t 8583
procmail: [7401] Wed Jan 31 06:27:52 2007
procmail: Executing "formail -X To: | sed 's/^To: *//' | sed 's/^.*[<<]//' |
sed 's/[>)].*$//'"
procmail: [7401] Wed Jan 31 06:27:52 2007
procmail: Assigning "TO=$USER1(_at_)$DOMAIN(_dot_)com"
procmail: Executing "echo $TO | sed 's/@.*$//'"
procmail: Assigning "USER=$USER1"
procmail: Assigning "DELIVERMAIL=/usr/lib/cyrus-imapd/deliver"
procmail: Executing "formail,-rtzxFrom:"
procmail: Assigning "TO="
procmail: Assigning "IMAP=/usr/lib/cyrus-imapd/deliver -e -a $USER1 -m
user.$USER1"
procmail: Assigning "BACKUP=/usr/lib/cyrus-imapd/deliver -e -a $USER1 -m
user.$USER1.Backup"
procmail: Assigning "SPAM=/usr/lib/cyrus-imapd/deliver -e -a $USER1 -m
user.$USER1.SPAM"
procmail: Assigning "SENDMAIL=/usr/lib/sendmail"
procmail: Match on ! "^To: mikee(_at_)$DOMAIN(_dot_)com"
procmail: Executing "/usr/lib/sendmail,-t"
procmail: Assigning "LASTFOLDER=/usr/lib/sendmail -t"
procmail: Notified comsat: "rmatus@:/usr/lib/sendmail -t"
From root(_at_)$DOMAIN(_dot_)com Wed Jan 31 06:27:52 2007
Subject: *** SPAM *** American General Financial Services $15,000 personal lo
Folder: /usr/lib/sendmail -t 8583
procmail: Unknown user "$USER2"
550 5.1.1 <$USER2(_at_)$DOMAIN(_dot_)com>... User unknown
procmail: [7820] Wed Jan 31 06:27:56 2007
procmail: Executing "formail -X To: | sed 's/^To: *//' | sed 's/^.*[<<]//' |
sed 's/[>)].*$//'"
procmail: [7820] Wed Jan 31 06:27:56 2007
procmail: Assigning "TO=$USER1(_at_)$DOMAIN(_dot_)com"
procmail: Executing "echo $TO | sed 's/@.*$//'"
procmail: Assigning "USER=$USER1"
procmail: Assigning "DELIVERMAIL=/usr/lib/cyrus-imapd/deliver"
procmail: Executing "formail,-rtzxFrom:"
procmail: Assigning "TO="
procmail: Assigning "IMAP=/usr/lib/cyrus-imapd/deliver -e -a $USER1 -m
user.$USER1"
procmail: Assigning "BACKUP=/usr/lib/cyrus-imapd/deliver -e -a $USER1 -m
user.$USER1.Backup"
procmail: Assigning "SPAM=/usr/lib/cyrus-imapd/deliver -e -a $USER1 -m
user.$USER1.SPAM"
procmail: Assigning "SENDMAIL=/usr/lib/sendmail"
procmail: Match on ! "^To: mikee(_at_)$DOMAIN(_dot_)com"
procmail: Executing "/usr/lib/sendmail,-t"
procmail: Assigning "LASTFOLDER=/usr/lib/sendmail -t"
procmail: Notified comsat: "$USER1@:/usr/lib/sendmail -t"
From root(_at_)$DOMAIN(_dot_)com Wed Jan 31 06:27:56 2007
Subject: *** SPAM *** American General Financial Services $15,000 personal lo
Folder: /usr/lib/sendmail -t 8583
------------------- message with procmail output
____________________________________________________________
procmail mailing list Procmail homepage: http://www.procmail.org/
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail