Debian – Postfix as SMTP server for Gmail. (“Send mail as” google option)

debiangmailpostfixsmtpssl

I have a vps on ovh.com runing debian 7. I want to set up my gmail account to send, and recieve mail on (for example) myname@example.com address. I searched google for hours and couldn't find a solution to my problem. I need a tutorial on how to set it up.

I've already configured postfix to forward mails sent to myname@example.com using this guide.

I receive mails, but they're unencrypted. Gmail displays a warning saying that ip-xxx-xx-xx.net (ovh provided i guess) did not encrypt this message. It seems that i have tls not configured.

My domain is configured as it should (i think) – example.com MX pointing at mail.example.com and mail.example.com A pointing at myserverip.

I tried to add smtp server to google (send mail as) and it sees the server on port 25 (postfix default) but it displays error:

Authentication failed. Please check your username/password.
[Server response: 535 5.7.8 Error: authentication failed: authentication failure code(535)

So i need a tutorial which will guide me on how to set up postfix as SMTP server that i can add to my gmail account, so i can send emails from gmail using my alias (myname.example.com), receive on this adress with encryption.

UPDATE

I changed something and it seems like there is some authentication error.
Google greets me with something like this :

Authentication failed. Please check your username/password.
[Server response: Unspecified Error (SENT_SECOND_EHLO): Smtp server does not advertise AUTH capability code(0) ]

Best Answer

Add the following lines to main.cf and restart the postfix

smtp_tls_security_level = may
smtp_tls_protocols = !SSLv2, !SSLv3
smtp_tls_mandatory_protocols = !SSLv2, !SSLv3
smtp_tls_mandatory_ciphers = high

For debugging you can use

smtp_tls_loglevel = 1 
Related Topic