download and parse the attachment coming with emails automatically
Jeff Schroeder
jeff at zingstudios.net
Mon Apr 3 17:42:43 MDT 2006
Bibhor asked:
> Is it possible to automatically capture the attachment sent to an
> email address before they are downloaded by the client program like
> outlook? Once captured I would like to parse the content of the
> attachment.
It depends on the mail server (MTA) you're using. For qmail, you could
put the following in your tcpserver.smtp file:
:allow,QMAILQUEUE="/var/qmail/bin/myscript"
This assumes you've compiled qmail with the QMAILQUEUE patch, and that
TCPServer is handling incoming connections. If so, all incoming
messages will be piped to /var/qmail/bin/myscript, which can be a
simple Bash script like this:
#!/bin/bash
out=/tmp/`date +%s`$$
cat > $out
if [ -z "`grep 'evil stuff' $out`" ]; then
cat $out > /var/qmail/bin/qmail-queue
rm -f $out
fi
This creates a file with a unique filename (the date in seconds, plus a
process ID) and checks whether the file contains "evil stuff". If not,
the message is piped to qmail-queue, which delivers it. Otherwise the
message isn't delivered, and you'll have a copy in /tmp.
Obviously this is a quick hack, and I spent about three minutes
designing it, so you can probably make it more robust. :) But the
point is that it's possible to do all sorts of interesting things prior
to mail delivery...
HTH,
Jeff
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 191 bytes
Desc: not available
Url : http://plug.org/pipermail/plug/attachments/20060403/fa42fa6b/attachment.bin
More information about the PLUG
mailing list