Configure Mail Server to receive mail from any domain

Vinod K picture Vinod K · Jan 23, 2011 · Viewed 7.6k times · Source

I have a postfix mail server on ubuntu on my virtualbox,now the domain of the mail server is abc.com...hence it receives mail from any "from address" but the "to address" needs to be proper i.e a valid user in the mailserver.

Now,in my project i am sending fake mails to user whose mail id consists of other domains too...like cde.com

My final objective is to show the mails in the mail server.

When i tried that ,it goes directly in to the mailserveer logs i.e /var/log/mail.log i.e as an error

is there any way i can store these mails in the mailserver??

Answer

mailq picture mailq · Mar 17, 2011

You want not only a Catch-All configuration like accepting any mail to *@abc.com but also to have a Catch-Anything configuration to accept any mail to *@* ?

This is possible if you have the PCRE support compiled into Postfix. Then you need virtual users in your configuration (see the Posfix documentation) and tweak it as follows:

Make sure that your Postfix is already configured to accept mail for at least one user and one domain. And that this is tested.

1) In main.conf set

virtual_alias_domains =
virtual_alias_maps = hash:/etc/postfix/virtual_forwardings, pcre:/etc/postfix/virtual_forwardings.pcre virtual_mailbox_domains = hash:/etc/postfix/virtual_domains, pcre:/etc/postfix/virtual_domains.pcre

The hash: parts are the known from the docs. And the pcre: parts are new. The hash: parts can also be omitted.

2) Create the file virtual_domains.pcre with the following content:

/^.*/ OK

This accepts any domain as valid recipient domain.

3) Create the file virtual_forwardings.pcre with the following content:

/@.*/ [email protected]

This forwards any local part of any domain to the Postfix user [email protected]. Make sure that this is a valid virtual or local user.

In this configuration it seems that Postfix is an Open Relay, but it does not relay for other domains. It accepts mails for any domain and locally delivers the mail to one mailbox.

Sometimes you will then notice a log entry telling you something like "don't list abc.com in mydestination and virtual config". This warning can be ignored as this "strange" setup is not usual.