I've had some luck using Postfix to relay emails sent to my server to multiple GMail accounts, but now I would like to go the other way around.

That is, use the gmail "Add another email as your own" SMTP configuration feature in order to allow me and another user to send emails under the domain associated with the server. I haven't really found a clear answer on how to do this or what the issues with this setup are. Would appreciate any pointers on this.

I am using Debian hosted on Digital Ocean.


If you want to use gmail as a relay for postfix with multiple users the basics are as follows:

Add the following lines to main.cf (all files in /etc/postfix)

relayhost = [smtp.gmail.com]:587
smtp_sasl_auth_enable = yes
smtp_sender_dependent_authentication = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_password_maps = hash:/etc/postfix/sender_relay
smtp_sasl_security_options = noanonymous
smtp_tls_CAfile = /etc/postfix/cacert.pem
smtp_use_tls = yes

Create a file sasl_passwd with the following contents:

user1@example.com    user1@gmail.com:password1
user2@example.com    user2@gmail.com:password2

Create a file sender_relay

user1@example.com  [smtp.gmail.com]:587
user2@example.com  [smtp.gmail.com]:587

Full details are at Postix SASL README There is a recipe to generate a self signed certificate for smtp_tls_CA_file at Postfix TLS README

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.