RSS feed
<< January 3, 2008 | Home | January 5, 2008 >>

Simple email service request

My previous post briefly explains the language that a web server uses to communicate. Web servers aren't the only services on the internet. Another really popular service is the one that handles the transmission of email. This server uses SMTP instead of HTTP to communicate. I've included some sample code to demonstrate a conversation in SMTP.

This is a vbs script to send an email. I've replaced the items in bold with bogus information to avoid pissing off any admins.

dim objShell
Set objShell = CreateObject("wscript.shell")
objShell.Run "telnet smtp.someisp.net 25"
WScript.Sleep 1000
objShell.SendKeys "EHLO test.com{ENTER}"
WScript.Sleep 1000
objShell.SendKeys "MAIL FROM: someone@someisp.net{ENTER}"
WScript.Sleep 1000
objShell.SendKeys "RCPT TO: someone@someisp.net{ENTER}"
WScript.Sleep 1000
objShell.SendKeys "DATA{ENTER}"
WScript.Sleep 1000
objShell.SendKeys "Subject: Test script message{ENTER}"
WScript.Sleep 1000
objShell.SendKeys "This is a test message.{ENTER}"
WScript.Sleep 1000
objShell.SendKeys ".{ENTER}"
WScript.Sleep 1000
objShell.SendKeys "QUIT{ENTER}"

Here's a shell script (UNIX) to run the commands automatically.

{ sleep 1 ; echo "EHLO test.com" ; echo "MAIL FROM: patrick@qantel.com" ; echo "RCPT TO: patrick@qantel.com" ; echo "DATA" ; echo "Subject: Test script message" ; echo "This is a sample body." ; echo "." ; echo "QUIT" ; sleep 1 ; } | telnet smtp.qantel.net 25

Here's a transcript of the conversation again with info in bold replaced.

220 smtp.someisp.net Microsoft ESMTP MAIL Service, Version: 6.0.3790.3959 re
ady at  Fri, 11 Jan 2008 13:40:10 -0800
EHLO test.com
250-smtp.someisp.net Hello [208.228.218.144]
250-TURN
250-SIZE
250-ETRN
250-PIPELINING
250-DSN
250-ENHANCEDSTATUSCODES
250-8bitmime
250-BINARYMIME
250-CHUNKING
250-VRFY
250-TLS
250-STARTTLS
250-X-EXPS GSSAPI NTLM
250-AUTH GSSAPI NTLM
250-X-LINK2STATE
250-XEXCH50
250 OK
MAIL FROM: someone@someisp.net
250 2.1.0 someone@someisp.net....Sender OK
RCPT TO: someone@someisp.net
250 2.1.5 someone@someisp.net
DATA
354 Start mail input; end with .
Subject: Test script message
This is a test message.
.
250 2.6.0  Queued mail for del
ivery
<< January 3, 2008 | Home | January 5, 2008 >>