But this is not often enough; we still need to send emails from the system command line on occasion. This guide will show you 5 Ways to Send An email from the Linux Command-Line. This is useful for sending emails from shell scripts, cronjobs, and other automated processes.
There are many ways to send emails from the command line, so I will go through a few that most people use. To send an email from the Linux command line, you can use either of the options mentioned below.
1. Using the Linux Command Line ‘sendmail’
Sendmail is a commonly used SMTP server that is included with almost every Linux/Unix distribution. Sendmail is a Linux command-line program that helps you to send an email. To send an email using the Linux command ‘sendmail‘, follow the steps below.
Create a file with the following email content:
Subject: The subject line will be used as the email’s subject.
Now use the following command to send an email.
2. Using the Linux ‘mail’ Command
The most popular command for sending emails from a Linux terminal is mail. To send an email, use a few of the examples below.
Attachments are indicated by the -a
suffix. For Debian-based systems that use the mailutils package, use -A.
You might run into the following issue: Bash: mail: command not found We may also use comma-separated emails in order to send the email to several recipients at once.
3. Using the Linux ‘mutt’ Command
Mutt is mostly used to read emails from local user mailboxes from a Linux terminal, but it can also be used to read emails from POP/IMAP servers. The mutt order is identical to the mail command. To send an email, use a few of the examples below.
Send an email with a file attachment.
4. Using the Linux ‘SSMTP’ Command
sSMTP allows users to send emails from a Linux command line to an SMTP server. Using the following command to send an email to the user admin@example.com. Now, enter your email’s subject as seen below, using the keyword Subject. Then type the message you want to send to the recipient. To send the email, click CTRL+d (d) after you have finished your message.
5. Using the Linux ‘telnet’ command
All system administrators, in my experience, use the telnet command to test remote port connectivity or log in to the server remotely. Most Linux newbies are unaware that we can also send email via telnet, which is a safer way to troubleshoot email sending issues.
Here’s an example of how to send an email using telnet. The user input is highlighted in red, and the remaining text represents the commands’ responses.
Saad Shafqat
Related posts
New Articles
Quick Guide to Downgrade One UI 7 Beta to Stable One UI 6 on Samsung
As Samsung enthusiasts eagerly embrace the latest features and enhancements in One UI 7 Beta, some users may find themselves…