Ubuntu: How do I configure Postfix to prioritize users over aliases?



Question:

I'm running Postfix on my Ubuntu server, and I'm having a problem with aliases.

As of now, I have a single user account set up (user@example.com) on my mail server, a catch-all to user@example.com, and a couple aliases redirecting elsewhere.

However, whenever I try to add a new user (user2@example.com), my emails still go through my catch-all to my own account. Obviously, this is unacceptable behavior and I need this fixed.

My initial server was set up according to this Digital Ocean writeup.

What can I do to get Postfix's priority to be users, aliases, and then catch-alls?


Solution:1

Apparently I didn't search well enough.

To do this, create a virtual-cancel.cf file in /etc/postfix with the following information:

user = <DATABASE_USER>  password = <DATABASE_PASSWORD>  hosts = <DATABASE_HOST>  dbname = <DATABASE_SCHEMA>  query = SELECT email from <USERS_TABLE> WHERE email='%s'  

Then, in your main.cf file, add your virtual-cancel.cf file before your standard alias mapping:

virtual_alias_maps = mysql:/etc/postfix/virtual-cancel.cf, mysql:/etc/postfix/mysql-virtual-alias-maps.cf  

Lastly, restart Postfix, and enjoy everything working.


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »