Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

This is more of a general setup question, and I'm looking for information on where to get started.

Basically, I am using google apps to host my domains personal email, BUT I also need to send email from a hosted machine that appears to be from the same domain. The hosted machine never needs to read/get mail, only send it (from various php scripts). So basically, I have

  1. several users that use gmails interface
  2. several php scripts that are attempting to send email from Note: Sending emails from the PHP scripts to another domain works fine.

Here is where I don't know what to do:

  1. Sending emails from the PHP server to my google app users, who have addresses like always FAILS with an error. Postfix detects that I am 'sending an email to myself', and aborts. What I would like it to do is to treat like any other domain, and look up its MX record and send the email as normal.

  2. Also, i've noticed that it defaults to setting the from address to Is there anyway to change this?

Here is my file if this helps: myhostname = mydomain =

myorigin = $mydomain
relayhost =
inet_interfaces = loopback-only
local_transport = error:local delivery is disabled


share|improve this question

The problem is having your hostname set to your domain name. By default postfix sets mydestination to include $myhostname. If your hostname were server1.$mydomain, your config would work. As it stands, postfix thinks that mail for $mydomain shoudl be handled locally yet local delivery is disabled, so it gives up.

In general, hostnames should not be your domain name, but rather a subdomain of your domain name.

share|improve this answer

Regarding your second question, the from address can be set using the additional_headers parameter of the PHP mail() function, see - the second example at the bottom of that page shows how to set the From address.

share|improve this answer

Your Answer


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