Skip to content

Setting Up OSPOS with Postfix and Gmail SMTP Server

Bones edited this page Apr 28, 2024 · 8 revisions

Setup Postfix to work with Gmail on Linux Mint 21.3 Cinnamon, Ubuntu 22.04.4 LTS, or Ubuntu 24.04 LTS

You need 2-Step Verification on your Google Account and will need to request an app password to use Gmail:

https://support.google.com/accounts/answer/185833

After enabling "Less Secure Apps" on your Gmail account, next step is to install Postfix on your Linux Mint system. You can do this by running following command:

sudo apt-get install postfix

The command will prompt you to select mail server configuration type. Choose "Internet Site" and click "Ok." This will launch a configuration wizard that will guide you through setup process. Accept all the defaults through the rest of the install.

Once you have installed Postfix, next step is to configure it to work with Gmail SMTP. This involves editing main configuration file located at /etc/postfix/main.cf.

To edit the file, open it in your preferred text editor using following command:

sudo nano /etc/postfix/main.cf

Then edit the following lines in the file to match the following:

relayhost = [smtp.gmail.com]:587
smtp_use_tls = yes
smtp_sasl_auth_enable = yes
smtp_sasl_security_options =
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_tls_CAfile = /etc/ssl/certs/ca-certificates.crt

To authenticate your Gmail account with Postfix, you need to create a password file. This file will contain your Gmail email address and password.

To create password file, run following command:

sudo nano /etc/postfix/sasl_passwd

Then add following line to the file:

[smtp.gmail.com]:587 your_email@gmail.com:your_app_password

Ensure you have a space between 587 and your_email and no spaces after your_app_password.

Replace "your_email" with your Gmail email address and "your_app_password” with your requested Gmail app password.

After adding line, save and exit the file.

Set the permissions with:

sudo chmod 600 /etc/postfix/sasl_passwd

Next, run following command to create a hash map of password file:

sudo postmap /etc/postfix/sasl_passwd

This command will create a new file called sasl_passwd.db in same directory as sasl_passwd file.

After configuring Postfix and creating password file, you need to restart service for changes to take effect.

To restart Postfix, run following command:

sudo service postfix restart

In OSPOS, under SETTINGS > CONFIGURATION > SETUP&CONF > EMAIL set:

Protocol: smtp
SMTP Server: localhost
SMTP Port: 25
SMTP Encryption: None 

Leave the rest blank and submit.

You should be able to send receipts and invoices from OSPOS now.

Clone this wiki locally