Electronic mail is a method of exchanging messages between people using electronic devices. There are several methods to send an email, in this guide we are going to focus on sending an email from Linux CLI using SMTP.
Requirements send an email from CLI using SMTP :
- Linux with sudo permissions
- SMTP details for your email
- Installing epel-release on your system by using the following command.
yum install epel-release
- Installing SMTP on your system by using the following command.
sudo yum install ssmtp
- Open the following file in an editor.
sudo vi /etc/ssmtp/ssmtp.conf
- Add the following lines to the file:
- Save the file by pressing the Esc key, type `:wq` to write the file and exit the editor.
mailhubcould be already defined in the ssmtp.conf file and make sure you edit the definition instead of adding a new
- Send the email using the following command.
echo -e "To: email@example.com\nFrom: Sender Name <firstname.lastname@example.org>\nSubject: Email from CLI\n\nTest Email sent using SMTP from CLI" | ssmtp -v email@example.com
Congratulations now you know how to send email from Linux using SMTP.