Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
I had solve this issue with cronjob and ripmime. – kockiren Aug 30 '11 at 8:15
Can you elaborate your solution? – mbx Mar 27 '12 at 8:21
up vote 1 down vote accepted

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

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

With crontab -e you can add this Task:

*/1 * * * *     sh /home/ >> /var/log/ripmime_ftp.log

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

share|improve this answer

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.

share|improve this answer
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 8:08

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.