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
<b>HELO rhel1</b>                        # 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
<b>MAIL FROM: ivan@rhel2</b>
250 2.1.0 Ok
<b>RCPT TO: david@rhel1</b>
250 2.1.5 Ok
<b>DATA</b>
354 End data with <CR><LF>.<CR><LF>
<b>Subject: Subject goes here.</b>
<b>Body goes here.</b>
<b>.</b>                                # End body with '.' and Enter                            
250 2.0.0 Ok: queued as 5C3E5E12EA
                                 # Quite interactive mail session with ctrl + ']'
<b>quit</b>
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: