1

I'm trying to build a solution to transfer attachments from Mail to an FTP folder. Are there any suggestions to solve this task?

My first idea was to write a shell script which fetches the mail from the Cyrus /var/imap folder and searches for the mail attachment finally writing it into a pdf file. As this does not seem to be the intended way of solving this issue, there might be a better one.

kockiren
  • 886
  • 2
  • 14
  • 35

2 Answers2

1

With ripmime and cronjob you can solve this problem. Ripmime is a tools to fetch MIME parts of a Mail. You can fetch text and attachments and extract it to an folder. With cronjob you can start a shellscript that looks into Maildir and starts ripmime for each Mail.

Install ripmime from http://www.pldaniels.com/ripmime/

After that I use this shellscript for fetch the attachments:

for file in /var/spool/cyrus/mail/x/user/username/*. ; do
    echo "$file"
    ripmime -i $file -d /home/username
    rm $file
done

With crontab -e you can add this Task:

*/1 * * * *     sh /home/ftp-scripts.sh >> /var/log/ripmime_ftp.log

After you get a Mail in /var/spool/... this Script call ripmime and extract the Attachment to ftp dir.

kockiren
  • 886
  • 2
  • 14
  • 35
0

I cannot support the way you want it! Email is not for sending files. See this question and the answers: Why do we still have such small email attachment filesize restrictions?

FTP already is for file transfer. So do not wrap files in mails to get them transferred. If you don't want to transfer files via FTP then look for something different. But not Email.

mailq
  • 16,882
  • 2
  • 36
  • 66
  • Thx for your answer, but i can't change the way to do. We get Mails with PDF Attachment from some External Services. And now i try to separate the Attachment to give access to our Customer by FTP. I can't change the way to get the PDF Files. – kockiren Aug 29 '11 at 10:53
  • It is right that SMTP is not the way to transfer files but everybody get Mails with Attachments like PDF or something else. And the issue was to extract Attachments from mail to publish it over ftp (the right protocol). Ripmime is the right way to do this, it think. – kockiren Aug 30 '11 at 14:05
  • This does not look like an answer. Its not helpful at all. – mbx Mar 27 '12 at 08:08