Would you like to learn how to send Gmail from Ubuntu Linux command-line? In this tutorial, we are going to show you all the steps required to send Gmail e-mail messages using only the command line of a computer running Ubuntu Linux.
• Ubuntu version: 18.04
Hardware List:
The following section presents the list of equipment used to create this Ubuntu tutorial.
Every piece of hardware listed above can be found at Amazon website.
Ubuntu Playlist:
On this page, we offer quick access to a list of videos related to Ubuntu installation.
Don’t forget to subscribe to our youtube channel named FKIT.
Ubuntu Related Tutorial:
On this page, we offer quick access to a list of tutorials related to Ubuntu installation.
Tutorial – Send Gmail from Ubuntu Linux Command-line
First, we need to enable your Gmail account to receive connections from external programs.
Open your browser and access your Gmail account.
In our example, the following URL was entered in the Browser:
On the login screen, enter your Gmail username and password.
After the login, you need to access the following URL:
• https://myaccount.google.com/lesssecureapps
Select the option to enable the use of less secure applications.
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.
# sudo apt-get update
# sudo apt-get install ssmtp
Edit the ssmtp.conf file to connect to our Gmail account.
# vi /etc/ssmtp/ssmtp.conf
root=virtualcoin.videos@gmail.com
mailhub=smtp.gmail.com:465
FromLineOverride=YES
AuthUser=virtualcoin.videos@gmail.com
AuthPass=kamisama123
UseTLS=YES
In our example, we are using the Gmail account virtualcoin.videos@gmail.com.
In our example, the Gmail account virtualcoin.videos@gmail.com is using the password kamisama123.
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 using the command-line” | ssmtp your.email@gmail.com
Keep in mind that you have to change the e-mail address used above.
The account your.email@gmail.com was used only as an example.
If the test was successful you are good to go.
If the test was unsuccessful, the following message may be presented.
• ssmtp: Authorization failed (534 5.7.14 https://support.google.com/mail/answer/78754 v24-v6sm2921112pfl.31 – gsmtp)
To solve this problem, you need to access the following URL .
• https://accounts.google.com/DisplayUnlockCaptcha
Select the option to unblock your account.
Try again to send the email using the command-line.
If the test was successful you are good to go.