I am not sure that this was the right solution in the first place but I have Postfix up and running on my Ubuntu VPS with G-Suite using

relayhost = [smtp.gmail.com]:587

Mail is delivering fine, however, all mail is being delivered as 'me@me.com' I host about different 15 websites for people and would rather not have their contact forms, user signups, etc. Showing up as an email from 'me@me.com'.

For example;

define('website_url', 'http://'.$_SERVER['HTTP_HOST']);
define('EMAIL_FROM', 'noreply@'.$_SERVER['HTTP_HOST']);

Submitting these forms still, results in emails showing as being sent from 'me@me.com'

I have also tried using this snippet in an individual VirtualHost file with no luck.

php_admin_value sendmail_path "/usr/sbin/sendmail -t -i -fclient@client.com"

I found that code from these questions: Configuring php mail() per domain, Apache, virtual hosts, and default sender for sendmail

Using 'sendmail' in the command line and changing the 'From:' address doesn't seem to work either.

All I want to do is be able to have the emails that I enter in From and Reply-To used, rather than 'me@me.com'. Any insight would be greatly appreciated.

  • you should not use gmail relay service, they will do address rewriting, it's extremely unprofessional. Sign up for a real Email Service Provider (gmail is an inbox provider) like mailgun, look into email authentication (spf, dkim, dmarc) as authenticated smtp is becoming a requirement especially over IPv6 networks. serverfault.com/questions/48428/… Oct 2 '17 at 23:56

I assume the me@myDomain.com is the Google account that you are using to connect to the server with. Google's servers do not let you set a random from address when using them as a relay. This would be a large security hole for them and their users. I believe that you can add the alias emails in your Google mail under:

Settings > Accounts and Import > Add another email address

Once confirmed, you can send from those addresses from the web interface. I think you should be able to send via those from your page as well.


  • Thank you. In that case, maybe I shouldn't be using Google as a Relay at all? I wouldn't be able to add the email addresses to my account as an alias as a lot of these websites are for businesses. Is there a simpler way to set up outgoing email to be sent from whatever From address I would like, per domain?
    – Jesse
    Oct 2 '17 at 22:58
  • If you run your own mail server, even a basic Linux one, you can set yourself up to send as whatever you would like. The only thing that would stop you would be if the domains that you are sending as have SPF records set up, but that is not very common. That is also a non-issue if you manage the domains. Oct 3 '17 at 1:20

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.