Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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 username@foo.com interface
  2. several php scripts that are attempting to send email from automated@foo.com. 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 user@foo.com 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 foo.com 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 www-data@foo.com. Is there anyway to change this?

Here is my main.cf file if this helps: myhostname = foo.com mydomain = foo.com

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

Thanks

share|improve this question

2 Answers 2

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 http://php.net/manual/en/function.mail.php - the second example at the bottom of that page shows how to set the From address.

share|improve this answer

Your Answer

 
discard

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