1

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?

2 Answers2

6

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.

LapTop006
  • 6,466
  • 19
  • 26
  • If you're having problems getting your script to run, you might want to read about *smrsh* (Sendmail restricted shell) at http://www.thevisionworld.com/vision-helpdesk-faqs-exim-postfix-qmail-sendmail-email-piping.html. – Cristian Ciupitu Apr 14 '10 at 12:12
4

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.

Cristian Ciupitu
  • 6,226
  • 2
  • 41
  • 55