Monday, October 22, 2007

command line to send test email via SMTP

Because I always forget this, here is the command line syntax for sending a test email through an SMTP mail server. Commands to enter at a prompt are in RED.

telnet 25

Connected to
Escape character is '^]'. Smail- (#2 1998-Jul-16) ready at Mon, 27 Nov 2000 13: 34:55 -0600 (EST)

250 Hello ( from address
250 ... Sender Okay
250 '' Recipient Okay.
354 Enter mail, end with "." on a line by itself
From: Meredith Foo
To: Joe
Subject: Test Message

This is only a test.

250 Mail accepted
221 closing connection

Don't forget that if your telnet session is hanging, the key combination of CTRL-] will exit you to the command prompt of telnet (Windows) or the shell prompt (Unix). If you're in Windows, simply type "quit" at the telnet command prompt in order to exit.

Expanding upon this simple test email, I've written some instructions on how to automate emails via shell script that some of you might find useful:


No comments:

Feel free to drop me a line or ask me a question.