June 30, 2014

How to Send Mail from the Command Line with Telnet

You can easily test your mail configuration from a linux server with telnet.

$ telnet rhel1 25
Trying 172.168.1.1...
Connected to rhel1.
Escape character is '^]'.
220 rhel1.localdomain ESMTP Postfix
HELO rhel1                        # Note that "HELO" is not a misspelled. It is the command for telnet services.
250-rhel1.localdomain
250-PIPELINING
250-SIZE 10240000
250-VRFY
250-ETRN
250-ENHANCEDSTATUSCODES
250-8BITMIME
250 DSN
MAIL FROM: ivan@rhel2
250 2.1.0 Ok
RCPT TO: david@rhel1
250 2.1.5 Ok
DATA
354 End data with <CR><LF>.<CR><LF>
Subject: Subject goes here.
Body goes here.
.                                # End body with '.' and Enter                            
250 2.0.0 Ok: queued as 5C3E5E12EA
                                 # Quite interactive mail session with ctrl + ']'
quit
221 2.0.0 Bye
Connection closed by foreign host.

For a more detail description, please see http://www.ehow.com/how_5209651_use-sendmail-command-line.html.

No comments: