Send mail from Linux CLI

Follow this blog to send and email from Linux CLI

Send mail from Linux CLI

The following are the steps to take for sending mails via postfix without username password authentication

For SMTP 25 port and STARTTLS 587 port

Use the following method if your postfix server is listening on port 25 and 587

Using telnet command

telnet mail.example.com 587

or

telnet mail.example.com 25

depending on the port

Using ncat command

ncat mail.example.com 587

or

ncat mail.example.com 25

depending on the port

For SMTPS 465 port

Using openssl command

openssl s_client -connect mail.example.com:465 -crlf -quiet

Common steps after establishing connection

220 services.vigneshn.in ESMTP Postfix

HELO example.com

250 mail.example.com

MAIL FROM: vignesh@example.com

250 2.1.0 Ok

RCPT TO: toaddress@example.com

250 2.1.5 Ok

DATA

354 End data with <CR>.<LF>

SUBJECT: This is the subject
This is the message
.

250 2.0.0 Ok: queued as 61527CA41EC

QUIT

221 2.0.0 Bye

ctrl+C to exit

Now you can check if the email has been delivered - Remember to check spam also