procmail
[Top] [All Lists]

Re: splitting large mail msgs.

1999-12-11 21:07:10

On Dec 11,  4:37pm, Silver wrote:
Subject: N: Recipe needs help (Silver)
Would someone be so kind as to pick this recipe apart?

Josh, I think what you're trying to do is split up large messages
and forward them to another e-mail address, split into smaller messages.
Is that right?


PMDIR=.procmail
LOGFILE=$PMDIR/test.log
HOME=/home/silver

:0:
{
:0w
| $HOME/split -b150
cat $HOME/xaa | mail -s 1 silver(_at_)mobile(_dot_)net
cat xab | mail -s 2 silver(_at_)mobile(_dot_)net
cat xac | mail -s 3 silver(_at_)mobile(_dot_)net
cat xad | mail -s 4 silver(_at_)mobile(_dot_)net
cat xae | mail -s 5 silver(_at_)mobile(_dot_)net
rm $HOME/xa*
}

I don't think procmail is going to accept all those individual
shell commands above.  You could fix that problem by add \'s for
continuation, and semi-colons between the commndas, that really isn't
what you want.  Probably easier, and more general, is the following:

SPLISIZE=100000
MYADDR=Savinien(_at_)excite(_dot_)com
ALTADDR=silver(_at_)mobile(_dot_)net

## check that the message exceeds message max
## if it does, then format the header to forward the
## e-mail to the required address, and pass the entire
## message to split_send.
:0
* > $SPLITSIZE
* !^X-Loop:.*$MYADDR
| formail -rI"To: $ALTADDR" -A"X-Loop: $MYADDR" | splitmail -d -i split

The recipe above checks if the message size exceeds $SPLITSIZE
bytes, which is arbitrarily set to 100000 in this example.  If
them message exceeds the limit, and there is no accidental
e-mail loop, it formulates a new messages that forwards to
$ALTADDR and adds a loop safeguard, and then sends this message
to the Unix splitmail command.  Here's the into. to 'splitmail':

NAME
       splitmail - Split a large mail message into MIME-compliant
       partial messages

SYNOPSIS
       splitmail  [-d] [-v] [-s splitsize] [-p prefix]  [-i   id-
       suffix] [file-name]

DESCRIPTION
       The splitmail program will take an email message and break
       it up into smaller pieces using the "message/partial" type
       defined by MIME, the proposed Internet standard for multi-
       media mail formats.
       [...]

The -d option tells splitmail to deliver the message, and '-i split'
adds a unique suffix beginning with the string "split" to each
newly generated message-id, that is derived from the original
message id.  Splitmail looks at the SPLITSIZE env. var. to
determine the proper max. e-mail size.

It may be that your receiving mail client can't handle
this fancy MIME way of sending split e-mails, but if it can, then
the script above might work for you.  Otherwise, you might
have to roll your own splitmail, perhaps in Perl or C, that
splits message into smaller pieces and sends it.  The MIME
way is safer/better because it will cleanly handle big mails with
binary attachments, etc.

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