7

I get the following error trying to send an email to my Google Apps Email at admin@mydomain.com from my Postfix server.

to=, relay=local, delay=0.09, delays=0.07/0/0/0.02, dsn=5.1.1, status=bounced (unknown user: "admin")

Is there a way I can force it to not use the LOCAL relay and treat admin@mydomain.com as outside email and not look for a user in the current postfix configuration.

I am trying to email the full email address "admin@mydomain.com" not only "admin".

I have the Google Apps MX record on mydomain.com + SPF record which before was:

v=spf1 include:_spf.google.com ~all (emailing to admin@mydomain.com used to work with that record)

But I had to change it to v=spf1 a mx ip4:MY.IP.HERE include:_spf.google.com ~all

Ivo Sabev
  • 177
  • 1
  • 1
  • 5

3 Answers3

9

Set the fallback_transport variable to relay , that way it'll send it to Google or whatever server it should, if doesn't find the user locally.

If you never want the mail to be sent to a local user change the mydestination variable to localhost , that way it'll only forward locally email addresses ending in .localhost

It would look like that in your main.cf file:

mydestination = localhost.localdomain, localhost
fallback_transport = relay
HopelessN00b
  • 53,385
  • 32
  • 133
  • 208
RDSM
  • 91
  • 1
  • 2
  • 1
    Would you literally type in 'localhost.localdomain, localhost'? Or would you substitute 'localdomain' with the actual domain? – pgunston Dec 10 '14 at 01:39
  • @pgunston I believe you type "localhost" literally. The point being that "admin@localhost" would still get delivered to a local mailbox, but "admin@my.actual.domain.com" would get relayed off the machine. – Darren Cook Dec 12 '16 at 10:25
5

Yes you can. Don't use admin as the recipient. Use something that is "outside" like admin@mydomain.com.

This only works if mydomain.com is not the domain configured in Postfix. Because Postfix thinks everything is local when you configured it to be local.

You should provide WAY more information than "it doesn't work". What are your configured domains, relay hosts, transport maps, MX records and the like?

mailq
  • 16,882
  • 2
  • 36
  • 66
  • I have only one configured domain "mydomain.com", no other fancy stuff that is not out of the box Postfix. – Ivo Sabev Aug 15 '11 at 18:46
  • And there is the problem. You told "mydomain.com" belongs to Postfix. But then you want that domain to be outside. That does not fit. – mailq Aug 15 '11 at 18:54
  • 1
    I am a bit confused on the matters related to postfix :) I fixed the issue by not setting the mydestination param in main.cf – Ivo Sabev Aug 15 '11 at 19:00
  • Fine. That is what I proposed. – mailq Aug 15 '11 at 19:04
  • I wish I can find example where you can have the myhostname = mydomain.com and still send emails to admin@mydomain.com that are not relayed locally. – Ivo Sabev Aug 15 '11 at 19:06
  • 2
    Nothing more easy than that! Set it to `myhostname = thehost.mydomain.com`. That's why it is called myhostname and not mydomainname. – mailq Aug 15 '11 at 19:09
0

It could simply be that within postfix's main.cf you have your target email domain listed. In this example we're going to assume the following:

  1. On this server you are hosting the example.com LAMP/LEMP website.
  2. That you have an online contact form (eg. php) which sends emails to info@example.com (from info@example.com to info@example.com)
  3. That your example.com emails are actually on GSuite or some other service. Not on this server.

Symptoms: If you change the online form to send emails to your personal email joe@foo.com it works fine. But nothing arrives at your info@example.com inbox.

Remedy: Check to see if your email domain is listed under "mydestination" in the postfix config

grep mydestination /etc/postfix/main.cf
mydestination = $myhostname, example.com, my.actual.hostname, localhost
-----------------------------^^^^^^^^^^^--------------------------------

vi /etc/postfix/main.cf
# removed example.com
mydestination = $myhostname, my.actual.hostname, localhost

service postfix reload

That fixed it for me! Hope it helps you.