Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I need to setup a mail server that has the following functionality: if a user sends an email to a specific address on this server, the server must first check if the email has a PDF attachment, do some processing to that PDF file and then reply to the user's initial mail with the new PDF file attached.

My question is how would it be possible to achieve this functionality, and what software / mail server do you recommend?

I'm thinking that it can be solved the following way: when the server receives a new email it executes an external Python script that checks the attachment, processes the PDF file and then sends it back in the user's mailbox. What mail server would be able to do this, and what configurations does it need?

share|improve this question
add comment

2 Answers 2

up vote 6 down vote accepted

Cristian has it, but a simpler optoin is to just add a line in /etc/aliases/ like:

pdf-user    "|/usr/local/bin/script-that-does-pdf-stuff"

Then your script simply reads the e-mail from standard in, then processes it and submits it via sendmail.

This functionality should work on most *nix MTA's, although postifx and exim are the two smart choices.

share|improve this answer
    
If you're having problems getting your script to run, you might want to read about smrsh (Sendmail restricted shell) at thevisionworld.com/…. –  Cristian Ciupitu Apr 14 '10 at 12:12
add comment

If you use Postfix, you can set the mailbox_command option to run your Python script on every message, but I think you'll have a lot of functionality to implement.

Another solution would be to use procmail for local delivery and configure it to send (pipe) the messages to your Python script. This autoresponder example might help you. The advantage of this solution is that your script can be simpler. There's no need for it to be a full local delivery agent.

share|improve this answer
add comment

Your Answer

 
discard

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.