I want to configure my Postfix server as accepting all incoming mails to any arbitrary users who don't have to exist on the system, say [email protected]. Now Postfix says, User unknown in local recipient table. What I want is to accept this e-mail without rejecting it and pipe it to my python script. Any help would be gladly appreciated.
Configuring Postfix All of the options you need for the service are located in /etc/postfix . The main configuration file for the Postfix service is located at /etc/postfix/main.cf . Within the configuration file, there are many options that you can add, some of them more common than others.
For installing Postfix server, your user should have sudo privileges (admin rights for installing postfix). If you want to receive emails from internet you should have DNS Records for Your Mail Server. You need to make sure Port 25 is open so that Postfix can receive emails from other SMTP servers.
You can use
luser_relay - Optional catch-all destination for unknown `local(8)` recipients.
Add the following to your main.cf
.
#/etc/postfix/main.cf
#...
#...
mydestination = $myhostname, localhost.$mydomain, localhost, mydomain.com
local_recipient_maps =
luser_relay = catchall
alias_maps = hash:/etc/aliases
#...
#...
and the following to your aliases
file.
#/etc/aliases
catchall: |/path/to/your/python_script.py
Run the following commands
postalias /etc/aliases
service postfix reload
and you can test the setup by following command
echo "test email"|mail -s 'Test email' [email protected]
Emails to unknown users will be delivered to the python script. Hope that helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With