Krzysztof Kowalczyk Blog  •  Notes  •  My Software  •  My Documents

Unix for masochists, or the art of e-mail forwarding with procmail

Unix is for truly masochistic. Consider my recent adventures of setting up something as trivial as e-mail forwarding. All I wanted is that e-mail delivered to my Unix account was kept locally as well as forwarded to my gmail account (reading e-mail in pine over ssh connection isn't as fun as it sounds).

Knowing nothing I had to google for information, armed only with one keyword: sendmail. I google, I read here and there and I get to know about .forward file and procmail. So I create the setup cobbled together from several different places:

$HOME/.forward is:

"|exec /usr/bin/procmail || exit 75"

$HOME/.procmailrc is:
PATH=/bin:/usr/bin:/usr/local/bin
MAILDIR=$HOME/mail
PMDIR=$HOME/.procmail
LOGFILE=$PMDIR/log
INCLUDERC=$PMDIR/general.rc

$HOME/.procmail/general.rc is:
:0 c
*
! my-gmail-account@gmail.com

:0
*
$DEFAULT
It took me, literally, hours of reading, debugging and trying different variations of this stuff.

But that's not everything. Before my battle was over I had to fix two other problems.

First, my sendmail uses smsrh i.e. restricted shell, for very noble security reasons. That means that it can't see /usr/bin/procmail in .forward. The fix is simple:
cd /etc/smsrh
ln -s /usr/bin/procmail procmail
Of course, to arrive at this fix I first had to happen to figure out sendmail's error message from bounced e-mail and google for the exact message to figure out how to fix it.

The other problem is that if I didn't have root privileges on this box I wouldn't be able to fix it at all.

There was one more thing: it turns out procmail is very picky about file permissions. For good reasons, I'm sure, but it doesn't change the fact that it's another thing I had to figure out from log files and googling. The fix (from http://www.ii.com/internet/robots/procmail/qs/#forward):
cd $HOME
chmod go-w,a+x .
chmod go-w .procmailrc
chmod 644 .forward

All I wanted is to have my e-mail forwarded. On Exchange-baseds systems all I needed to do was to create a server-side rule using a simple UI interface from within Outlook.

← newer • 300 of 661older →