Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Configure Mail Server to receive mail from any domain [closed]

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??

like image 240
Vinod K Avatar asked Jan 23 '11 04:01

Vinod K


Video Answer


2 Answers

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.

like image 99
mailq Avatar answered Oct 24 '22 05:10

mailq


FTR:

An alternative way to do it by sending any mail to "some.local.user" (a shell user)

Required: postfix-pcre package

in main.cf

luser_relay = some.local.user
local_recipient_maps =

virtual_alias_maps = pcre:/etc/postfix/virtual_alias.pcre

mydestination = $myhostname, pcre:/etc/postfix/mydestination.pcre

File: /etc/postfix/virtual_alias.pcre (catchall mapped to "some.local.user")

/\/@/            some.local.user

__

File: /etc/postfix/mydestination.pcre (we accept whatever you throw at us)

/.*/    OK
like image 2
AlexB Avatar answered Oct 24 '22 05:10

AlexB