- 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]:587smtp_sasl_auth_enable = yessmtp_sasl_security_options = noanonymoussmtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
- Next, create a new file called
sasl_passwdin the/etc/postfixdirectory:sudo nano /etc/postfix/sasl_passwd - Add the following line to the
sasl_passwdfile, replacing[email protected]andpasswordwith your Gmail address and password:[smtp.gmail.com]:587 [email protected]:password - Save and close the
sasl_passwdfile, 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.
