Autoreplies

From LQWiki
Jump to navigation Jump to search

Autoreplies

In order to set up an autoreply in postfix for virtual recipients while still delivering mail as normal, set up a rule in a virtual alias table:

 /etc/postfix/main.cf:
   virtual_alias_maps = hash:/etc/postfix/virtual
 /etc/postfix/virtual:
   user@domain.tld user@domain.tld, user@domain.tld@autoreply.mydomain.tld

This delivers mail to the recipient, and sends a copy of the mail to the address that produces automatic replies. The address can be serviced on a different machine, or it can be serviced locally by setting up a transport map entry that pipes all mail for autoreply.mydomain.tld into some script that sends an automatic reply back to the sender.

DO NOT list autoreply.mydomain.tld in mydestination!

 /etc/postfix/main.cf:
   transport_maps = hash:/etc/postfix/transport
 /etc/postfix/transport:
   autoreply.mydomain.tld  autoreply:
 /etc/postfix/master.cf:
   # =============================================================
   # service type  private unpriv  chroot  wakeup  maxproc command
   #               (yes)   (yes)   (yes)   (never) (100)
   # =============================================================
   autoreply unix  -       n       n       -       -       pipe
       flags= user=nobody argv=/path/to/autoreply $sender $mailbox

This invokes /path/to/autoreply with the sender address and the user@domain.tld recipient address on the command line.

For more information, see the pipe(8) manual page, and the comments in the Postfix master.cf file.