Postfix to execute a specific script after receiving mail

Source: Internet
Author: User

This article main reference: Http://serverfault.com/questions/258469/how-to-configure-postfix-to-pipe-all-incoming-email-to-a-script

???? During the Postfix mail server Setup, it is sometimes hoped that postfix will be able to move to execute a specific script after receiving the message. Similar to the actual function has, mail automatic reply program, mail content filtering and so on. This function can be implemented by configuring the Postfix. This article describes a way to move to execute a specific shell script after Postfix receives the message.
???? The method used in this article is to solve the idea is: by modifying the transmission table (transport_maps), so that Postfix received the message, not directly forwarded to the MDA, and transferred to a specific script program.
???? Specifically, five steps are required:
1. Create a transmission table to indicate what requirements will be forwarded to the message
2. Compiling the transfer table into a familiar data format for Postfix
3. Set up a service in the Postfix master.cf file to tell Postfix that the message needs to be forwarded to a specific script
4. Set the Transport_maps parameter in the main.cf of Postfix and tell Postfix to use the transfer table

???? Here are the specific actions for each step
1, create the file /etc/postfix/transport , tell postfix the following domain name received mail will start the service named Mytransportname
mydomain.com mytransportname:
2. Compile the file into a Postfix recognized format
$ sudo postmap /etc/postfix/transport
3, in the/ETC/POSTFIX/MASTER.CF to increase the transmission service:

mytransportname unix - n n - - pipe
flags=FR user=localuser argv=/path/to/my/script.py
${nexthop} ${user}

Where the flags are the service identity; user is the username (attention to the permissions issue); argv is the address of the script program. Here, the script that this service needs to execute is /path/to/my/script.py
4. Finally, in the, add the /etc/postfix/main.cf configuration of the transmission table in
transport_maps = hash:/etc/postfix/transport

???? After you complete the steps above, restart Postfix (service postfix restart). Note that the script must have executable permissions and that the user user has permission to execute the script.

Postfix to execute a specific script after receiving mail

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.