Ever wondered to send email from command line but after that you must thought that this is not possible.But you are wrong this is possible.So how you can send email from command line you must be thinking about this only.So don’t worry we will tell you how you can send email from Command Line so follow these simple steps to send email.
Steps to send email from Command Line
SSMTP is a open source SMTP server available for Linux.You can install SSMTP on your Linux with the simple command.To install SSMTP in Ubuntu type the following command in your Terminal.
sudo apt-get install ssmtp
Enter your password and it will start downloading ssmtp.
Then you have make some changes ssmtp.conf file.To do that type the following command in the terminal and press enter.
sudo gedit /etc/ssmtp/ssmtp.conf
This will open ssmtp conf file.After that you have to configure it works with existing mail host like Gmail.So here is the configuration of ssmtp with Gmail.So just copy this code and paste it on ssmtp conf file.
Now replace your-email-address with your email which you will use to send emails make sure that email account is on G mail and then replace your-gmail-login-password with your password.Save the file by pressing Ctrl+S.
Now again open the terminal and use the following command to send emails.
Body of email
Replace receiver-email-address with the email address whom you want to send email,replace subject-here with your email subject and body of email with content of your mail.After that press Ctrl+D and it will send the mail to the email address which you chosen above.
if you get the following error while sending email
ssmtp: Authorization failed (534 5.7.9 http://support.google.com/accounts/bin/answer.py?answer=185833 bk8sm8525341pad.28 – gsmtp)
Then you have to enable access for less secure apps and it will work.Still if you are having any problem then feel free to contact us.If you like this article please share and subscribe to our newsletter to get latest updates directly in your inbox.