Sending email via Gmail relay through postfix

From Notes_Wiki
Revision as of 13:10, 14 October 2015 by Saurabh (talk | contribs) (Created page with "<yambe:breadcrumb>Postfix_server_configuration|Postfix server configuration</yambe:breadcrumb> =Sending email via Gmail relay through postfix= To send email via Gmail relay t...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

<yambe:breadcrumb>Postfix_server_configuration|Postfix server configuration</yambe:breadcrumb>

Sending email via Gmail relay through postfix

To send email via Gmail relay through postfix use:

  1. Configure gmail to use less secure apps using:
    1. Login into Gmail account and go to Settings -> Accounts -> Google Account Settings
    2. In "Google Account Settings" go to Sign-in and Security.
    3. In Sign-in and security change "Allow less secure apps:" to ON
  2. edit /etc/postfix/sasl_passwd and put something like
    smtp.gmail.com <gmail-email-address>:<gmail-password>
  3. cd /etc/postfix
  4. chmod 600 sasl_passwd
  5. postmap hash:/etc/postfix/sasl_passwd
  6. edit /etc/postfix/main.cf and after relayhost comment lines insert
    smtp_sasl_auth_enable = yes
    smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
    smtp_sasl_security_options =
    smtp_tls_security_level = may
    relayhost = smtp.gmail.com:587
  7. service postfix restart
  8. echo "Test email using postfix" | mail -s "Gmail relay test" saurabh@sbarjatiya.com

To troubleshoot look at /var/log/maillog. In log lines look at value of ctladdr such as 'ctladdr=saurabh (501/501)'. Then look at /var/mail/saurabh or login as user saurabh and use 'mail' command to see error message sent by Gmail server.


<yambe:breadcrumb>Postfix_server_configuration|Postfix server configuration</yambe:breadcrumb>