I'm trying to get postfix to forward email to my domain which is hosted by gmail. As I don't have any users on my server nor do I want to.

Here's how I have things set up. Let's say you and I have a domain called mcdonalds.com.

The registrar has mcdonalds.com MX records pointing to gmail. Everything works for like a year.

Now we set up a server to host a website.

Then we create a mail account called sales@mcdonalds.com and send mail locally from the server using roundcube.

This works.

We can send mail to cnn.com, to serverfault.com or to any/everyone.

BUT we cannot send mail to our own domain, mcdonalds.com.

So I cannot email to info@mcdonalds.com, to bob@mcdonalds.com or to support@mcdonalds.com.

It gives the following error:

SMTP Error (450): Failed to add recipient "bob@mcdonalds.com" (4.1.1 <bob@mcdonalds.com>: Recipient address rejected: User unknown in virtual mailbox table).

I'm guessing because it is looking at the local server to find the mailbox, which doesn't exist.

So how to I tell the server for any mail going to mcdonalds.com for bob@mcdonalds.com to send to my external mail server, and not to lookup on the local www box we set up with zpanel?

Any ideas?


You can use transport for that (http://www.postfix.org/transport.5.html).

put in /etc/postfix/transport

mcdonalds.com   :aspmx.l.google.com

Don't forget to run postmap /etc/postfix/transport after that.

  • tried that.. but no luck. Added the line to transport and then did the postmap.. – orlandoresorts Mar 28 '13 at 13:27
  • error was Mar 28 09:24:51 server postfix/pickup[10079]: DC00615A20D7: uid=0 from=<sender@mcdonalds.com> Mar 28 09:24:51 server postfix/cleanup[10094]: DC00615A20D7: message-id=<20130328142451.DC00615A20D7@www.mcdonalds.com> Mar 28 09:24:51 server postfix/qmgr[10080]: DC00615A20D7: from=<sender@mcdonalds.com>, size=322, nrcpt=1 (queue active) Mar 28 09:24:52 server postfix/pipe[10085]: DC00615A20D7: to=<recipient@mcdonalds.com>, relay=dovecot, delay=0.18, delays=0.12/0/0/0.07, dsn=4.1.1, status=SOFTBOUNCE (user unknown) – orlandoresorts Mar 28 '13 at 13:28
  • You could leave local_recipient_maps empty in main.cf but this would not be a good idea because it will forward to gmail all emails for your domain, even if recipients does not exist. If this server is is exposed in internet it could be a big problem. You could list all existing recipients in a file and use this file in local_recipient_maps (something like local_recipient_maps = hash:/etc/postfix/usernames). postfix.org/LOCAL_RECIPIENT_README.html – Laurentiu Roescu Mar 28 '13 at 13:51
  • You could also change mydomain in main.cf to something like server.mcdonalds.com. This way the server will not think that mails for @mcdonalds.com are for itself and it will forward them to MX. – Laurentiu Roescu Mar 28 '13 at 13:58
  • I did try that too beforehand! (changing the mydomain to xzy.com I made up.. and no luck :( ) The local recipent maps is already blank. (the email addresses are fixed.. 4 addresses . But I don't want to staticly assign addresses just in case I add more people.. but the usernames wouldn't work cuz I have no local mailboxes... right? – orlandoresorts Mar 28 '13 at 14:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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