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 am creating a python script to deliver local mail using various means. The problem is this:

  • This script has to accept multiple virtual domains defined in /etc/postfix/virtual
  • The script does the checking if the recipient is valid and the contents are as expected and exits with the appropriate code (4.x.x 5.x.x) if not

The problem is that I want the bounce to come from the recipient address (orig_to) or bounce@recipientdomain, is this possible?


Setup:

/etc/postfix/virtual:

@domain1     pymail
@domain2     pymail
@domain3     pymail
@domain4     pymail
@domain5     pymail

/etc/postfix/master: (contains)

pymail    unix  -       n       n       -       -       pipe
  flags=FR user=pymail argv=/path/to/script.py ${sender} ${recipient}

/etc/postfix/transport:

* pymail:

/etc/postfix/main.cf:

pymail_destination_recipient_limit = 1
transport_maps = hash:/etc/postfix/transport
virtual_alias_domains = domain1 domain2 domain3 domain4 domain5
virtual_alias_maps = hash:/etc/postfix/virtual
share|improve this question

2 Answers 2

up vote 0 down vote accepted

I couldn't find a way to do this, so in the end I just wrote in to the python script to send an error mail to the sender from the correct address.

share|improve this answer

The problem is that when postfix delivers your mail to python, it has already been accepted.

DO NOT accept mail you don't intend to deliver; backscatter bounce is one of the worst kinds of spam.

Instead, define valid recipients in postfix, instead of python, and let postfix reject unwanted or undeliverable mail.

You will also need to play with the arguments to pipe(8) and the various destination concurrency options, to get this working smoothly.

share|improve this answer
    
Thanks, but this script is for email to SMS, so the email has to be validated by python, not by postfix (users need to be verified, credits, destination number etc etc). And I read that postfix uses the script's exit status code (if you exit with non 0 status and a string like 4.x.x or 5.x.x) to generate the delivery/bounce status. –  zeyus Jul 30 '12 at 23:24

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.