| 9 | During the initial installation, we installed `postfix`. Now we need to add google credentials to it so that your server can send mails using Google. |
| 10 | |
| 11 | Edit `/etc/postfix/main.cf` |
| 12 | |
| 13 | Change following. ( DO NOT copy paste these in to the end of the file ) |
| 14 | |
| 15 | {{{ |
| 16 | |
| 17 | # TLS parameters |
| 18 | smtpd_tls_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem |
| 19 | smtpd_tls_key_file=/etc/ssl/private/ssl-cert-snakeoil.key |
| 20 | smtpd_tls_security_level=may |
| 21 | |
| 22 | smtp_tls_CApath=/etc/ssl/certs |
| 23 | smtp_tls_security_level=may |
| 24 | smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache |
| 25 | |
| 26 | relayhost = [smtp.gmail.com]:587 |
| 27 | smtp_use_tls = yes |
| 28 | smtp_sasl_auth_enable = yes |
| 29 | smtp_sasl_security_options = |
| 30 | smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd |
| 31 | smtp_tls_CAfile = /etc/ssl/certs/ca-certificates.crt |
| 32 | |
| 33 | }}} |
| 34 | |
| 35 | Create `/etc/postfix/sasl_passwd` with your Google username and password |
| 36 | |
| 37 | {{{ |
| 38 | [smtp.gmail.com]:587 thilinapathiedulk@gmail.com:MyPassw)<# |
| 39 | }}} |
| 40 | |
| 41 | where `MyPassw)<#` would be my password for google. On google you have to make sure, Less Secure Apps are enabled. |
| 42 | |
| 43 | now restart postfix |
| 44 | |
| 45 | `systemctl restart postfix` |
| 46 | |
| 47 | Test mail transport by `mail -s "Hello World" youremail@yourdomain.tld` |
| 48 | |