How to change from-address when using gmail smtp server

The short answer – you can’t.

Google rewrites the From and Reply-To headers in messages you send via it’s SMTP service to values which relate to your gmail account.

The SMTP feature of gmail isn’t intended to be an open or relay service. If it allowed any values for the From header, it would significantly dilute Google’s standing with spam services, as there would be no way to verify the credentials of the sender.

You need to consider alternatives. How are you planning to host your script/application/website when it’s finished: virtually every hosting solutions (shared/vps/dedicated server) will come pre-configured with an email transfer solution: be it sendmail or postfix on *nix, or IIS on Windows.

If you are intent on using gmail then you could:

====

Edit June 2015

It was suggested that GMail does allow sending via different addresses. As far as I can tell, this is for sending via the GMail wep app, and utilises your existing external SMTP server, which is not relevant to the original question.

====

Edit Nov 2013

Seeing as this is still getting a trickle of votes. A quick update.

Google have withdrawn their free GMail for domains. There are plenty of other free services around. One of note is Mandrill – a one-to-one email service intended for transactional emails (e.g. ecommerce orders etc.). It’s ran by MailChimp, who pretty much know all there is to know about sending email at volume. They also give you 12k/month free, which is rather nice.

Leave a Comment