procmail
[Top] [All Lists]

Re: Lean mean stripped down e-mail

2002-01-03 12:52:45
At 14:22 2002-01-03 +0000, Edward Wildgoose wrote:

I have a linux box configured with Postfix, procmail, etc and have
offered to look into hosting his e-mail if I can work out how to
clean-up and strip out attachments from his received messages.  It
occurs to me that there may already be some sort of add-in to mail
systems, or even a commercial provider, which can  offer a slimmed down
text only, no XHeader, etc e-mail server

You can strip these out on reception as you stuff them into the mailbox. This doesn't require a special mail server - just a special program called procmail.

If he's using the satphone only to read the messages on the road, but wishes to retain a full copy to read when he has a landline, be sure to preceed the filtering functions with a copy rule, or better yet, create an alias for the user address which sends the mail to TWO user mailboxes - one is their regular pop mailbox, which probably sees no filtering, and the other gets pumped through procmail and deposited in the mailbox he reads when using the satphone.

If his mail is stored to two mailboxes, you can then do things like deleting mailer-daemon messages from the satphone box, etc.


You could pump it through sed to strip out trailing whitespace (and/or to condense multiple blank lines, and possibly replace multiple space runs with tabs as appropriate). There are recipes in the archives which will remove certain identifyable freemail adbanner lines as well.

# If operating within ONE account, take all mail and deposit a copy in a
# mailbox the user can access later from a landline
:0c
landline-mail

# use stripmime (see the list archives for the URL) to strip HTML and
# attachments from the message, resulting in plaintext.
:0f
|/some/path/stripmime.pl

# strip trailing whitespace, condense multiple blank lines, poss remove
# freemail adbanners - this won't be a onelineer, but they are in the
# archives.
:0fb
|(some optional sed operation(s))

# Take a look at the archives over the past few days, where the
# "most efficient" manner of stripping all but certain headers was
# discussed.  You could strip most headers - including To:/Cc: (unless you
# need to be aware of other recipients), but I'd suggest retaining the
# Message-Id just because on the road you could use that to correlate a
# message to your landline mailbox.
:0 fhw
| formail -X"From " -XFrom: -XSubject: -XDate: -XMessage-Id -k

Also stage 2 of this is to monitor for new mail and second an e-mail
(which gets converted to an SMS message by the satellite company)
whenever mail arrives.  This would allow him to see if it was worth

Uh, these SMS messages will arrive on a one-for-one basis for new mail. If that's really what you want, put a copy flag on a recipe following the above filtering (well, it could appear before it if you wanted, but by doing it afterwards, you'll know that the message is just about in the user mailbox when the notice is sent, and not hung up on some other process):

:0ci
| formail -XSubject: -XFrom: -I"To: smsaddr(_at_)domain(_dot_)tld" -XTo: | 
$SENDMAIL -t

If you wanted to prefix the Subject with some marker like "[MAIL ALERT] ", you'd need to get the current subject value into variable (either using MATCH, or an assignment from formail), then stuff that into the header similar to how the To: address is being done above.

Alternatley, you could run a cron process that issues a notification to the user every hour on the hour or somesuch with current mail stats - # messages #bytes, etc.

elm has a simple shell script "messages" that reports how many messages there are in a mailbox (counts the ^"From " lines), the following is a stripped down bash-friendly version:

#!/bin/sh
# counts messages and reports spool size
if [ -s /var/spool/mail/$LOGNAME ]; then
 mcount=`egrep -c "^From " /var/spool/mail/$LOGNAME`
 read foo foo foo foo size foo <<EOF
`ls -l /var/spool/mail/$LOGNAME`
EOF
 echo "To: smsaddr(_at_)domain(_dot_)tld"
 echo "Subject: Mail Status $mcount/$size"
 echo
 echo "User $LOGNAME has $mcount message(s) totalling $size bytes."
fi

---
 Sean B. Straw / Professional Software Engineering

 Procmail disclaimer: <http://www.professional.org/procmail/disclaimer.html>
 Please DO NOT carbon me on list replies.  I'll get my copy from the list.

_______________________________________________
procmail mailing list
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail

<Prev in Thread] Current Thread [Next in Thread>