Subject: Re: Smail config problems (changing From: line)

From: Christophe Le Bars <[email-masked]>
Date: Fri, 5 Jul 96 20:52 MET DST

**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>
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>'somebody@linuxbox'.
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>
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
------------------------------------
<cut>
visible_name=ISP.com
-domains
hostnames=PPPNUMBER.ISP.com:LINUXBOX
<cut>
------------------------------------

Smail /etc/smail/routers file
------------------------------------
<cut>
smart_host:
	driver=smarthost, transport=smtp;
	path=smtp.ISP.com
<cut>
------------------------------------

Smail /etc/smail/transports file
------------------------------------
<cut>
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
<cut>
--------------------

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

a procmailrc file 
--------------------
# /etc/ips-mail
# Christophe Le Bars 1996 - public domain
PATH=/usr/local/sbin:/sbin:/usr/sbin:/usr/local/bin:/bin:/usr/bin
LOGFILE=/var/log/isp-mail
LOGABSTRACT=yes
# mail to clb (example 1!)
:0
* ^(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!)
:0
* ^(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...
:0w				
| /usr/local/sbin/isp-mail-error
------------------------------------

Then a script to use it... 
------------------------------------
#!/bin/sh
# /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
------------------------------------
#!/bin/sh
# /usr/local/sbin/isp-mail-error
# Christophe Le Bars 1996 - public domain script

TMPFILE=/tmp/isp-mail1.$$
LOGFILE=/tmp/isp-mail2.$$

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

rm -f $TMPFILE $LOGFILE

exit 0
------------------------------------

-- 
Christophe Le Bars - Email : [email-masked], [email-masked]
01001DEBIAN0LINUX0110ESPERANTO000000101011ML11111010010GNU01100001
101110100101000111111 Utilisez Linux Debian! 100101010010000110010