[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Smail config problems (changing From: line)

**On 04 Jul, In article "Smail config problems (changing From: line)",
**	MO (Mike Orr) writes:
MO>On Wed, 3 Jul 1996, Jean Orloff wrote:
MO>Sometimes I feel like just writing an smail-replacement script that would:
MO>** Deliver locally any mail to 'somebody (no hostname)' or to
MO>** Telnet smarthost SMTP and feed it any non-local mail, after changing
MO>From/Reply-to/Sender: from 'me(@linuxbox)' to 'smartaccount@ISP'.
MO>A companion receivemail script (or procmail + scripts) would:
MO>** Pop the mail and deliver it locally, changing To/Cc/Bcc: from
MO>'smartaccount@ISP' to 'me@linuxbox'.  (Possibly determining the local
MO>username from the comment part of the email address, as I've seen some
MO>people do.)
MO>** If no valid local account, forward to postmaster@linuxbox (or bounce
MO>it, but I'd rather see what it is).

Well, I have a config that can do that...

First Deliver locally and changing any non-local mail...

Smail /etc/smail/config file

Smail /etc/smail/routers file
	driver=smarthost, transport=smtp;

Smail /etc/smail/transports file
smtp:	driver=tcpsmtp, max_addrs=100, -max_chars, inet,
	remove_header="${if and{{origin:local}{dest:remote}} From}",
	insert_header="${if and{{origin:local}{dest:remote}} From: ${fullname} <ISP-ACCOUNT@${name}>}",
	append_header="${if and{and{{origin:local}{dest:remote}}{!header:organization}} Organization: LINUXBOX}",
	remove_header="${if {origin:local} Content-Length}",
	append_header="${if {origin:local} Content-Length: $body_size}";
	use_bind, defer_no_connect, -local_mx_okay, defnames

And now a "companion" (procmail + scripts) for the ISP incoming mail

a procmailrc file 
# /etc/ips-mail
# Christophe Le Bars 1996 - public domain
# mail to clb (example 1!)
* ^(To|Cc|Bcc):.*C(hristophe|\.)?( )?L(e|\.)?( )?B(ars|\.).* 
| formail -R "Cc:" "Old-Cc:" -R "BCc:" "Old-BCc:" -i "To: clb" | smail -eq -t -i	
# mail to od (example 2!)
* ^(To|Cc|Bcc):.*O(livier|\.)?( )?D(upond|\.).* 
| formail -R "Cc:" "Old-Cc:" -R "BCc:" "Old-BCc:" -i "To: od" | smail -eq -t -i	
# If no valid local account...
| /usr/local/sbin/isp-mail-error

Then a script to use it... 
# /usr/local/sbin/pop-isp-mail
# Christophe Le Bars 1996 - public domain script

touch /var/run/mail-pop-on
popclient -u ISP-ACCOUNT -P /etc/ppp/pop-psswd -c smtp.ISP.com |\
	formail -q- -z -s procmail -m /etc/isp-mail
rm -f /var/run/mail-pop-on

And a script for unknow ISP incoming mail
# /usr/local/sbin/isp-mail-error
# Christophe Le Bars 1996 - public domain script


cat - > $TMPFILE

ID=`formail -x "Message-ID"<$TMPFILE|cut -c2-`

[ "$ID" != "" ] || exit 1

cp $TMPFILE "/var/spool/isp-mail/$ID"
echo -e "\n pop-isp-mail ID error mail :\n" $ID "\n" >> $LOGFILE
mail -s "pop-isp-mail error..." postmaster < $LOGFILE


exit 0

Christophe Le Bars - Email : clebars@teaser.fr, clebars@debian.org
101110100101000111111 Utilisez Linux Debian! 100101010010000110010

Reply to: