Save an email attachment automatically to map with qmail and reformime
I'm trying to move attachment automatically to another locatie with the dot-qmail file.
My .qmail file
#------------------------------------------------------------
| condredirect pdf-junkmail headermatch 'X-Spam-Status: Yes'
| reformime -X /bin/sh -c "if [ "\${FILENAME#*.}" == "pdf" ]; then cat > /home/users/name/home/$(date +%Y%m%d)_\$FILENAME; fi"
# Forward not set
# Vacation Message not set
./Maildir/
This works for a simple mail with one attachment. My questions:
- How can I also move the mailmessage that belongs to this attachment to a mailbox named "done".
- Above command doesn't work with multiple attachments in one mailmessage? How can I ajust this line to work for multiple attachments?
- This doesn't work if the filename contains multiple dots like "how.areyou.pdf"
Thanks for the help
Here is a featured implementation for your problem.
First save and set permissions to this bash script for your user.
You will need to call it from your
.qmailfile:extract-pdf-attachments.shThen in you
.qmail: