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.
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 firstname.lastname@example.org < /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” email@example.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” firstname.lastname@example.org < /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” email@example.com,firstname.lastname@example.org < /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” email@example.com < /dev/null
Send email including attachment
# mutt -s “Test Email” -a /opt/backup.sql firstname.lastname@example.org < /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 email@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 firstname.lastname@example.org
Subject: Test SSMTP Email
Email send test using SSMTP
via SMTP server.
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
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: email@example.com
250 2.1.0 firstname.lastname@example.org… Sender ok
>rcpt to: email@example.com
250 2.1.5 firstname.lastname@example.org… Recipient ok
354 Enter mail, end with “.” on a line by itself
This email is for testing purpose
250 2.0.0 r9M95xgc014513 Message accepted for delivery
221 2.0.0 fbreveal.com closing connection
Connection closed by foreign host.
” margin_top=”50px” margin_bottom=”” animation_type=”slide” animation_direction=”left” animation_speed=”0.3″ class=”” id=””]