Advertisement
metalx1000

Postfix mail server run script

Oct 24th, 2016
715
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.87 KB | None | 0 0
  1. First, go to master.cf and register your script "myhook" by adding the following line:
  2.  
  3. myhook unix - n n - - pipe flags=F user=www-data argv=/path/to/script.sh ${sender} ${size} ${recipient}
  4.  
  5. Also, edit smtp line to tell Postfix to run the filter for any mail arriving via the SMTP delivery:
  6.  
  7. smtp      inet  n       -       -       -       -       smtpd        -o content_filter=myhook:dummy
  8.  
  9. Please note that if you are sending mails using the "sendmail" command, the filter will not trigger. In this case, add the option after the "pickup" delivery method:
  10.  
  11. pickup    fifo  n       -       -       60      1       pickup -o content_filter=myhook:dummy
  12.  
  13. Restart postfix: postfix reload
  14.  
  15. Make your script readable and executable by anybody: chmod +rx script.sh
  16.  
  17. Note that script is always triggered for any mail arriving. To specify exact address see @MariusMatutiae answer.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement