- Install Postfix on your server:
- On Debian/Ubuntu systems, you can use the following command:
sudo apt-get install postfix
- On CentOS/Red Hat systems, you can use the following command:
sudo yum install postfix
- On Debian/Ubuntu systems, you can use the following command:
- Once Postfix is installed, open the main configuration file using your favorite text editor:
sudo nano /etc/postfix/main.cf
- Find the following lines in the configuration file and modify them as follows:
relayhost = [smtp.gmail.com]:587
smtp_sasl_auth_enable = yes
smtp_sasl_security_options = noanonymous
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
- Next, create a new file called
sasl_passwd
in the/etc/postfix
directory:sudo nano /etc/postfix/sasl_passwd
- Add the following line to the
sasl_passwd
file, replacing[email protected]
andpassword
with your Gmail address and password:[smtp.gmail.com]:587 [email protected]:password
- Save and close the
sasl_passwd
file, then run the following command to create a hashed version of the file:sudo postmap /etc/postfix/sasl_passwd
- Finally, restart the Postfix service to apply the changes:
sudo service postfix restart
You should now be able to use Gmail’s SMTP server to send emails through Postfix.