

If you face difficulties, please be sure to let us know in the comments. If you use any other email vendor, replace mailhub in the above snippet with the appropriate server:port value. Append the file or replace with the entire file content with the following text: mailhub=:587Įven if you delete the entire config and replace it with just the above snippet, it should it work perfectly. If you are familiar with command line editors such as Nano, Vim, Emacs and others, feel free to use them. You need to edit the conf file: sudo gedit /etc/ssmtp/nf “Linuxhandbook advise you not to do any such configuration unless you are very sure.” It will enable all the users to send an email using the credentials in the config without forcing each user to have own email and password. Some of the other articles you might find online will guide you to store username and password in the configuration file (/etc/ssmtp/nf). Let’s assume, everyone uses the same SMTP server. Each user has to specify email and password each time they send a mail.

Since this article main focus is to send a mail, we are sticking to the basic setup of SSMTP.

In Ubuntu 18.04, you can install SSMTP as follows: sudo apt install ssmtp Configuring SSMTPĪfter this is done, we need to configure SSMTP. SSMTP is available as a package in most of the Linux distributions. Let’s see how you can send mail in Linux command line with the help of SSMTP. Sending emails from Linux terminal using SSMTP

If you want to know more about SMTP, please use this wiki article about SMTP. Finally, it will be forwarded to the recipient. When you send a mail, your client forwards it to your vendor’s SMTP server which then sends it to recipient’s email vendor. SSMTP is one of such client programs that can help you to send the emails. There are two software pieces needed: SMTP server (hosted by email vendor) and SMTP client that you have in your system. Though vendors like Outlook, Gmail usually use proprietary protocols, they provide SMTP services so that user can access their emails from any client. SMTP (Simple Mail Transfer Protocol) is one of the protocols (set of rules and formats for data and communication) used in sending and receiving emails. Let’s see more about sending emails from Linux command line. This is one of the many use cases where sending mails from Linux can help you big time. With the mail setup, it can automatically send you emails in case there is an alert. You use Fail2Ban on it to thwart unwarranted logins. Suppose you have a Linux server that you need to keep secured. The main question is why would you take the trouble of sending emails from Linux terminal? Did you know that you can send mail from Linux command line? That’s not surprising, I believe.
