How to Send Email from the Linux Command Line Using an SMTP Server (with SSMTP) [ 4 Easy Steps ]
We want to stay connected to everyone in the global world. In order to accomplish this, email is a widely used way of sending and receiving information. Linux systems also provide command-line tools for sending emails, which can be used to obtain system information, send emails from shell scripts, and so on.
Linux Command Line
Email is sent as system username@hostname when sent from a Linux terminal. These emails can be blocked or marked as spam by certain SMTP servers. As a result, we need a method that maximizes email delivery to the inbox. We would use this article to set up our server to transfer email from SMTP servers like Gmail, Amazon SES, and others. This article will show you How to Send Email from the Linux Command Line Using an SMTP Server (with SSMTP).
Step 1: Install SSMTP Server
SSMTP service packages can be found in the EPEL repository, so make sure you have the EPEL yum repository configured.
Step 2: Set up SSMTP
Add the following values to the SSMTP configuration file. I am going to use the Gmail SMTP server for this tutorial. If you want to set up with Gmail as well, make sure you already have a Gmail account.
In the configuration file, change the following values.
- mailhub: your SMTP server’s host/ip address and port
- UseSTARTTLS: If the SMTP server uses TLS, set it to Yes; otherwise, set it to No.
- AuthUser: Use your Gmail ID here.
- AuthPass: Use your Gmail ID’s password.
- TLS_CA_File: If you encounter an error such as “send-mail: Cannot open smtp.gmail.com:587,” this will take some time.
Step 3: Send a Test Email
Send a test email to an email address to test the setup. First, write the email in a text file, as follows:
Then, using the ssmtp command, send an email to “firstname.lastname@example.org”:
Let us see if there is something new in your inbox.
Step 4: Make SSMTP the default client.
Set SSMTP as your default mail server so that you can send emails via SSMTP with the mail command.
Verify the changes by following command:
Top 6 logo makers to try in 2023
As businesses and organizations continue to grow and evolve, logos become increasingly important as visual representations of their brand. In…
Leave a Reply