(keitai-l) Proxying E-mail (was: iAppli IMAP proxying service?)

From: Joseph Luk <joe_at_josephluk.com>
Date: 07/08/03
Message-Id: <BB60F797-B11B-11D7-A71D-0003935AD130@josephluk.com>
I too use the system Curt described where one uses a proxy for their 
incoming and outgoing mobile E-mail.  Curt was even nice enough to send 
me his Perl script, although I had a slightly different idea and just 
ended up coding a little procmail doody from scratch.

I've attached the code below.  Just drop it into a Procmail script if 
you have access to one, and change embedded strings as necessary.

Incoming mail goes to mobile@yourdomain -- this gets forwarded to your 
keitai and the sender's address reformatted for easy replying.

For outgoing mail, you send to sender--at--senderdomain@yourdomain.  
The script changes "--at--" to "@" and trims "@yourdomain" --> 
sender@senderdomain.

Mail is also archived into a folder (BIG plus -- lose your keitai and 
you can still read your E-mail).

The major problem is with long E-mail addresses that don't stand up to 
having --at-- @yourdomain" tacked on within the length limit.  I need 
to recode some of that script to take abbrevations for common 
senderdomains.

The other problem is that, at least on my mail server, emoji gets 
munged into a garbage character.  I tried asking this list about it, 
but was told "Enfour knows, but they're not going to tell you unless 
you pay up.  People have to eat too."  Yeah, but I'm just an individual 
and I'm not looking to profit from this...

My script is different from Curt's in that it lets you use subject 
lines, which I find quite useful.  But if you don't have Procmail 
installed obviously Curt's solution is more useful to you.

OK without further ado, here's the code!  Have fun people!

Cheers,
Joe



-------


# Mobile mail filters
MOBILEADDR=yourrealmobileaddress@docomo.ne.jp

# Net-To-Mobile (inbound) mail forwarder by Joseph Luk
:0
* ^TO_(mobile@yourdomain.com|m@yourdomain.com)
{
	# Transform the From line to make replying easier
	# add "--at--" delimiter and the @yourdomain.com
	
	FROM=`formail -f -zx "From:" | sed -e "s/ *([^)]*) *//g" -e 
"s/.*<\([^>]*\)>.*/\1/g" | sed -e "s/\@/--at--/"`
	FROM="$FROM@yourdomain.com"
	
	# save a copy in the received folder
	:0c:
	$HOME/mail/mobile

	# forward the mail to the mobile phone
	# kill the cc and bcc fields to avoid a loop if the mobile address is 
cc'd
	:0
	| formail -fk \
		-I "From: $FROM" \
		-I "To: $MOBILEADDR" \
		-I "Cc:" \
		-I "Bcc:" \
		-X "" \
	  | $SENDMAIL $SENDMAILFLAGS -t
}


# Mobile-To-Net (outbound) mail forwarder by Joseph Luk
:0
* $ ^From.*$MOBILEADDR
{
	# transform the To line
	# strip @yourdomain.com and transform the --at-- delimiter into an at 
sign
	RECIP=`formail -zx "To:" | sed -e "s/\@yourdomain.com//" -e 
"s/--at--/\@/"`
	
	# format the mail
	:0f	
	| formail -k \
		-I "From: My Mobile Phone <mobile@yourdomain.com>" \
		-I "To: $RECIP" \
		-X ""
	
	# save a copy in the sent folder
	:0c:
	$HOME/mail/mobile
	
	# send it to the recipient
	:0
	| $SENDMAIL $SENDMAILFLAGS -t
}
Received on Tue Jul 8 11:15:51 2003