How to send mail through Gmail On Ubuntu using ssmtp
Postfix is a flexible mail server that is available on most Linux distribution. Though a full feature mail server, Postfix can also be used as a simple relay host to another mail server, or smart host
Requirements
- Ubuntu 20.04
- Valid Gmail or Google App credentials
Now, we need to test if we can use the Linux command-line to send an email using Gmail.
Use the following command to install the required packages.
# apt-get update
# apt-get install ssmtp -y
Edit the ssmtp.conf file to connect to our Gmail account.
# vi /etc/ssmtp/ssmtp.conf
root=manas.tri@gmail.com
mailhub=smtp.gmail.com:587
FromLineOverride=YES
AuthUser=manas.tri@gmail.com
AuthPass=************
UseTLS=YES
UseSTARTTLS=YES
In our example, we are using the Gmail account manas.tri@gmail.com.
In our example, the Gmail account manas.tri@gmail.com is using the password XXXXXXXXX<hidden>.
You need to change the Gmail account and password to reflect your account.
Use the following command to send an email using the command-line.
# echo "E-Mail from cactiserver" | ssmtp manas.tri@gmail.com
No comments