Postfix setup catch-all email accounts using /etc/postfix/virtual

by on July 6, 2007 · 12 comments· LAST UPDATED July 6, 2007

in , ,

Q. How do I setup cacth-all email accounts under Postfix MTA? For example if an email send to, and, should be sent to the same email address.

This is useful if anyone of user mistypes an email address when they send it to me, or just guesses at a valid email address, then they will likely get an error message from my server such as user / email mail box does not exist. So I wish to set up a "catch all" address

A. Mapping is done using /etc/postfix/virtual file.
# vi /etc/postfix/virtual
Append code as follows, replacing domain and emailusername with actual values: emailusername

Save and close the file. Run following command:
# postmap /etc/postfix/virtual

Also make sure you have following line in /etc/postfix/ file:
virtual_alias_maps = hash:/etc/postfix/virtual

If you just added above, line reload postfix:
# service postfix reload

Caution: if you set up a catch-all email address, you will likely receive more unsolicited (spam) email.

Tweet itFacebook itG+ itDownload PDF versionFound an error/typo on this page?

{ 11 comments… read them below or add one }

1 omar August 6, 2008 at 9:02 am

I need to do something similar. I need the domain to forward emails to when emails sent to Is there a way to do that?
Thank you !


2 nixCraft August 6, 2008 at 9:15 am

create .forward file in users home directory (for user) and put email ID


3 sureshkumar February 26, 2009 at 12:23 pm

HI Vivek how can i Add multiple users for SMTP auth on postfix
but are not support gmail ….. can you help me please ….
in the virtual concepts support these concept……… waiting for your reply…..


4 Rob March 13, 2009 at 4:39 pm

Bump on sureshkumar’s question


5 nixCraft March 13, 2009 at 5:24 pm

I don’t think so it is possible to use multiple gmail account. sasl_passwd totally depends upon first part (hostname) to determine correct username:password when there are multiple entries in sasl_passwd. You need unique hostname for multiple entries:                

However, you can use something as follows in /etc/postfix/sasl_passwd:           username1:password1           username2:password2

Next set, /etc/postfix/sender_relay:           []:587           []:587

Setup as follows:

smtp_sender_dependent_authentication = yes
sender_dependent_relayhost_maps = hash:/etc/postfix/sender_relay
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
relayhost = []:587


6 Bob July 13, 2009 at 2:35 pm

What about if you have multiple domains and you all emails sent to bob@* to go to the bob user name but everything else to go to the jim username. How do you do that?


7 sumit September 11, 2009 at 8:29 pm

I want to configure postfix virtual so that all emails goes to one address.

I can’t specify individual domain in virtual as I don’t know. Can anyone help me on this?


8 Nd May 31, 2010 at 7:11 pm

Possible solution for those looking to catch everything (any domain):

Edit /etc/postfix/, change the ‘smtp’ declaration to:
smtp inet n – – – – smtpd -o content_filter=verp

And insert:
verp unix – n n – 10 pipe user=USER_HERE argv=PATH_HERE

Where ‘verp’ can be whatever you like, e.g. myfilter, mybouncehandler, etc.


9 mark mason February 23, 2011 at 6:15 am

I want to allow for email forwarding to my customers so we all have as our email addresses that forward to yahoo or gmail accounts. I can do this by hand on cpanel but I need a solution with an api to set up email forwards. Anybody know of a product?


10 Sohail December 24, 2012 at 3:20 pm

I want to dynamically create different mail id’s (,,….)for a user(abc) but not different users and not even aliases. whenever a user sends an email to newly generated mail id( it sholud get delivered to user(abc)’s mail box. Can anyone solve this up?


11 omer January 13, 2014 at 4:19 pm

Thank you brother. İt’s so good.


Leave a Comment

Tagged as: , , , , , , , , ,

Previous Faq:

Next Faq: