There are different approaches to send messages from the command line yet here, I am sharing a couple of choices utilized by general clients. You can utilize any choice given underneath to send email from Linux command line.

1. Sendmail

Sendmail is a most prominent SMTP server utilized as a part of the majority of Linux/Unix appropriation. Sendmail permits sending email from command line.

Use underneath guidelines to send email utilizing ‘sendmail’ command.

Make a record utilizing the following substance.

[root@testadmin ~]# cat /tmp/email.txt

Subject: Terminal Email Send

Email Content line 1
Email Content line 2

Subject line will be used as the subject for email.

Utilize the accompanying command to send the email.

[root@testadmin ~]# sendmail user@sample.com < /tmp/email.txt

2. Using ‘mail’ Command

Mail command is the most well-known command to send messages from Linux terminal. Utilize few of underneath cases to send an email.

[root@testadmin ~]# mail -s “Test Subject” user@sample.com < /dev/null

“-s” is utilized for characterizing subject for the email.

Likewise, we can send the email with a connection.

# mail -a /opt/backup.sql -s “Backup File” user@sample.com < /dev/null

Sometimes you may face the issue: Bash: mail: command not found

“-a” is utilized for connections.

Likewise, we can add comma isolated messages to send the email to various beneficiaries together.

# mail -s “Test Email” user@sample.com,user2@sample.com < /dev/null

3. Using ‘mutt’ command

Mutt is essentially utilized for perusing sends from Linux terminal from neighborhood client letter boxes, additionally helpful to peruse messages from POP/IMAP servers. Mutt command is minimal like mail command. Utilize few of examples cases to send email.

# mutt -s “Test Email” user@sample.com < /dev/null

Send email including attachment
# mutt -s “Test Email” -a /opt/backup.sql user@sample.com < /dev/null

4. Using ‘SSMTP’ Command

SSMTP enables clients to send messages from SMTP server from Linux command line. For instance to send an email to client admin@example.com utilize the following command.

Presently type your subject of the email as beneath with catchphrase Subject. After that compose your message to sent to the client, After completing your message press
CTRL+d (^d) to send the email.

# ssmtp admin@sample.com
Subject: Test SSMTP Email
Email send test using SSMTP
via SMTP server.
^d

5. Using ‘telnet’ Command

In my experience, all framework chairmen utilize telnet command to test remote port network test or log in to the server remotely. A large portion of a beginner in linux doesn’t realize that we can send email utilizing telnet likewise, which is a better approach to investigate email sending issues. The following is a case of sending email.

Blue marked text is the user input and remaining is the responses of that commands.

# telnet localhost smtp

Trying 127.0.0.1…
Connected to localhost.localdomain (127.0.0.1).
Escape character is ‘^]’.
220 fbreveal.com ESMTP Sendmail 8.13.8/8.13.8; Tue, 22 Oct 2013 05:05:59 -0400
Good Morning yahoo.com
250 tecadmin.net Hello tecadmin.net [127.0.0.1], pleased to meet you
mail from: sender@testadmin.net
250 2.1.0 sender@tecadmin.net… Sender ok
>rcpt to: myemail@ymail.com
250 2.1.5 myemail@ymail.com… Recipient ok
>data
354 Enter mail, end with “.” on a line by itself
>Haibo
This email is for testing purpose
Thanks
.
250 2.0.0 r9M95xgc014513 Message accepted for delivery
quit
221 2.0.0 fbreveal.com closing connection
Connection closed by foreign host.

[tagline_box backgroundcolor=”description=” shadow=”no” shadowopacity=”0.7″ border=”1px” bordercolor=”” highlightposition=”top” content_alignment=”left” link=”” linktarget=”_self” modal=”” button_size=”” button_shape=”” button_type=”” buttoncolor=”” button=”” title=”” description=”If you have any queries on how to access email clients via command line in linux feel free to leave us a message and our representative will get back to you.

” margin_top=”50px” margin_bottom=”” animation_type=”slide” animation_direction=”left” animation_speed=”0.3″ class=”” id=””]

[/tagline_box]