Retrieve mail and save attachment with fetchmail, procmail and uudeview.

Retrieve mail from user called user01 of server:

root:~> cat .fetchmailrc
poll "" proto IMAP user "user01" password "password" is user01 keep sslproto ''
mda '/usr/bin/procmail -d %T'
set logfile /home/user01/fetchmail.log

To save an attachment from an e- mail use procmail andUUDeview is a program that helps you transmit and receive binary files over the Internet, using electronic mail or newsgroups The UUDeview package includes both an encoder and a decoder. The decoder automatically detects the type of encoding used, offering MIME’s Base64 and BinHex as well as the popular uuencoding and the less frequently used xxencoding methods.

root:~> cat .procmailrc

# Now the actual unpacking part
# forward to uudeview and unpack
| uudeview -i +a +o -p /share/Shared/attachment/ -

And then run fetchmail command 😉

Leave a Reply

Your email address will not be published. Required fields are marked *