[HOW]OCS mail settings with GMAIL smtp server

Here we go. Im currently working on OCS 2.3.6.0 with PHP 5.5, MYSQL 5.5, Ubuntu Server 14.04.01 LTS. This is my first experience with OCS and i want to share my OCS mail settings.
Preparation :
OCS installed
gmail account

Step by step :

update your ubuntu server

sudo apt-get update

install required modules

sudo apt-get install libsasl2-modules postfix mailutils

select internet site

input system mail name: example.com

edit postfix configuration file

sudo nano /etc/postfix/main.cf

edit following line as your server domain

myhostname = ocs.example.com

config smtp username and password

sudo nano /etc/postfix/sasl/sasl_passwd

add following line to file

smtp.gmail.com:587 username@gmail.com:your_gmail_password

sudo postmap /etc/postfix/sasl/sasl_passwd

securing your password and hash database files

sudo chown root:root /etc/postfix/sasl/sasl_passwd /etc/postfix/sasl/sasl_passwd.db
sudo chmod 0600 /etc/postfix/sasl/sasl_passwd /etc/postfix/sasl/sasl_passwd.db

configuring the relay server

sudo nano /etc/postfix/main.cf

specify SMTP relay host

relayhost = smtp.gmail.com:587

add the following parameters to enable authentication at the end of file

enable SASL authentication

smtp_sasl_auth_enable = yes

disallow methods that allow anonymous authentication.

smtp_sasl_security_options = noanonymous

where to find sasl_passwd

smtp_sasl_password_maps = hash:/etc/postfix/sasl/sasl_passwd

enable STARTTLS encryption

smtp_use_tls = yes

where to find CA certificates

smtp_tls_CAfile = /etc/ssl/certs/ca-certificates.crt

sudo service postfix restart

go to your gmail account and do a setting

go to > my setting > sign-in & security > scroll to bottom > allow less secure apps:ON

test your outgoing mail from server

echo “body of your email” | mail -s “This is a Subject” username@gmail.com

check your gmail inbox and incoming mail should appears

Notes :
No need setting on ~./ocs/config.inc.php

test email from ocs back office

click on envelope icon



email from OCS system should appear on new user email

facing error sending mail to your own domain? just add (#) front of your destination domain list

sudo nano /etc/postfix/main.cf
mydestination = #example.com, ocs.example.com, localhost.example.com, localhost

have nice day :wink: