Sign up ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I had installed Posfix, Dovecot and MySQL on Debian (for example and configured its that external users are allowed to send mails only on this domain (using my SMTP). Also I configured that all mails (like * are forwarded to one mailbox Mostly I was following this guide.

Some my Postfix configuration:

virtual_alias_maps = proxy:mysql:/etc/postfix/
query = SELECT destination FROM forwardings WHERE source='%s'

| SOURCE | destination |
| | |

I’ve allowed my SNTP to receive only mails for by next way:

transport_maps = proxy:mysql:/etc/postfix/
query = SELECT transport FROM transport WHERE DOMAIN='%s'

| DOMAIN | transport |
| | : |
| * | error:Only allowing one domain |

All work as I expected but I need add possibility to send mails from local clients (like PHP) to external users. Unfortunately I have no ideas how I can do it.

share|improve this question
I think you're going about this wrong, you should just set mydestination to be, then allow relaying from mynetworks, usually and a selection of hosts connected in the same subnet.. –  NickW Mar 7 '14 at 10:58

2 Answers 2

up vote 1 down vote accepted

The default settings in postfix are to disallow relaying to anybody from outside the machine, and also only accept mail for domains hosted locally.

With that in mind, what you want to achieve is fairly straightforward. You should set mydestination like this (assuming that the postfix server is in

mydestination = $myhostname localhost.$mydomain localhost

Set myhostname to the hostname of the server something like and mydomain to

That will ensure that from the "outside" postfix will only accept mail for, then you can set up an alias to redirect all mail to to

Then you can set mynetworks to allow forwarding only from itself like this:

mynetworks =

This will do everything you asked for, and is much more flexible. You will probably need to do things like setting up an MX record, RDNS, and possibly other things that are beyond the scope of this answer.

share|improve this answer
Thank you very much. Actually I've realized that I chose a quite weird way to achieve my goal. I'll try to reconfigure the server in this way. –  Victor Mar 7 '14 at 16:00

Absolutely brilliant guide to set up email server with postfix, dovecot and mysql can be found here:

I've worked through it twice, once with Debian and the components mentioned there and once with Ubuntu, with slightly different versions of postfix and dovecot and with postgres instead of mysql.

Reading the guide and understanding it worth every minute spent and I always recommend it to people, even if they are going to have a smaller setup.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.