Here is How To Configure Ubuntu Server & WordPress To Use Google Apps Gmail for Domains. There are two ways – using plugin and server side configuration. We have talked about SMTP before. We have explained that there is associated reputation of Domain Name Mail Server. You can use this link to signup for Google Apps and use Gmail for domains. If you are from India, you can use our Partner Voucher code number AFEMP9X9C37FJX
to get off for the first year. You can cancel your account at anytime. As we have said, there are two ways, first we’ll go for the server configuration. Google Apps Gmail here means Gmail for Domains.
Configure Ubuntu Server To Use Google Apps Gmail
First, after signup / with existing Gmail Account, you need to visit this webpage of Google for Unlocking Captcha. Your DNS records should be complete and MX record must be present. You will need to use application specific password if you have enabled 2-factor authentication.
For relaying mails using Postfix, you need to install these :
---
1 | apt-get install postfix mailutils libsasl2-2 ca-certificates libsasl2-modules |
There are four configuration files :
1 2 3 4 | /etc/postfix/main.cf /etc/postfix/sasl_passwd /etc/postfix/tls_policy /etc/postfix/master.cf |
Check this location for SSL cert :
1 | cat /etc/ssl/certs/Thawte_Premium_Server_CA.pem |
Should give you this kind of output :
You do not have to purchase SSL certificate. This is server’s CA one. We want to put it here :
1 | /etc/postfix/cacert.pem |
We can use unix pipe :
1 | cat /etc/ssl/certs/Thawte_Premium_Server_CA.pem | sudo tee -a /etc/postfix/cacert.pem |
First we will open the main.cf
file :
1 | nano /etc/postfix/main.cf |
Basic configuration should go like this :
1 2 3 4 5 6 7 | relayhost = [smtp.gmail.com]:587 smtp_sasl_auth_enable = yes smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd smtp_sasl_security_options = smtp_tls_CAfile = /etc/postfix/cacert.pem smtp_use_tls = yes smtp_tls_policy_maps = hash:/etc/postfix/tls_policy |
We are providing you another optional configuration part of the file :
1 2 3 4 5 6 7 | #smtpd_tls_auth_only = yes smtpd_tls_key_file = /etc/postfix/newkey.pem smtpd_tls_cert_file = /etc/postfix/newcert.pem smtpd_tls_loglevel = 3 smtpd_tls_received_header = yes smtpd_tls_session_cache_timeout = 3600s tls_random_source = dev:/dev/urandom |
The above usually people do not say to avoid a bit few extra steps. Search our website with SSL certificate
and you will find how to generate newkey.pem
– these are used when OpenSSL support compiled with the package.
Then we will open the tls_policy
file :
1 | nano /etc/postfix/tls_policy |
This should have :
1 | [smtp.gmail.com]:587 encrypt |
Now the last one :
1 | nano /etc/postfix/sasl_passwd |
This should be edited rightly :
1 | [smtp.gmail.com]:587 admin@thecustomizewindows.com:PASSWORD |
Change admin@thecustomizewindows.com:PASSWORD
with yours one. Run these commands :
1 2 3 | sudo chmod 400 /etc/postfix/sasl_passwd sudo postmap /etc/postfix/sasl_passwd sudo postmap /etc/postfix/tls_policy |
That /etc/postfix/master.cf
needs to have an uncommented line :
1 | smtps inet n - n - - smtpd |
Read Postfix official documentations :
1 2 | http://www.postfix.org/TLS_README.html#client_tls https://help.ubuntu.com/community/Postfix |
Another SMTP Client is MSMTP. You should not install both the above stuff and this one.
1 | apt-get install msmtp ca-certificates |
1 | nano /etc/msmtprc |
Copy and paste the following in the text editor:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | defaults tls on tls_starttls on tls_trust_file /etc/ssl/certs/ca-certificates.crt account default host smtp.gmail.com port 587 auth on user admin@thecustomizewindows.com password PASSWORD from admin@thecustomizewindows.com logfile /var/log/msmtp.log <pre> You have to replace `admin@thecustomizewindows.com` with your email and `PASSWORD` with your password. Last step is : <pre>sudo chmod 0644 /etc/msmtprc |
So, these are two server side relay options. Many peoples has huge contribution for the whole guide including Major Hayden, Rahul Bansal and many. If you have WordPress on the domain, honestly it is better to take the second option.
Configure WordPress To Use Google Apps Gmail
There is a great WordPress Plugin :
1 | https://wordpress.org/plugins/wp-mail-smtp/ |
Official Screenshot on the repo will tell you the easy story. It is hugely used Plugin.
Tagged With /etc/ssl/certs/Thawte_Premium_Server_CA pem , google apps for ubantu , google apps for ubuntu , Ubuntu Google Apps authentication