Results 1 to 3 of 3
I'm very new at this, so pardon me if this question is very newbie-like.
I'm doing some testing against SMTP servers, and need to automate it a bit. What I ...
- 07-24-2007 #1Just Joined!
- Join Date
- Oct 2006
- Posts
- 7
Telnet SMTP bash script
I'm very new at this, so pardon me if this question is very newbie-like.
I'm doing some testing against SMTP servers, and need to automate it a bit. What I want to do, is make a bash script that telnets to an SMTP server and sends the commands and data, then quits. I've tried doing it like this (which is probably way off):
This works, up to the DATA command. What happens is that the lines after DATA isn't getting sent, and the connection ends with "cannot accept the message without body". So there's obviously some way of sending the data that I don't know. And I haven't been able to find anything usefull about it on the net, so therefore I'm askin here.Code:#!/bin/bash ( sleep 1 echo "ehlo x" sleep 1 echo "mail from:frommail" sleep 1 echo "rcpt to:tomail" sleep 1 echo "data" sleep 1 echo "subject:Test message" sleep 1 echo "from:frommail sleep 1 echo "to:tomail" sleep 1 echo " " #sleep 1 echo "Hello." sleep 1 echo "This is a test message." sleep 1 echo "Bye." sleep 1 echo "." sleep 1 echo "QUIT" ) | telnet 172.17.7.140 25
Thanks for all tips and help.
- 07-24-2007 #2
You use netcat for this, not telnet.
Code:[xxx@xxx src]$ nc localhost 25 << EOF > HELO localhost > MAIL FROM: user@whatever.com > RCPT TO: user@whatever.com > DATA > this is a test > . > QUIT
- 07-25-2007 #3Just Joined!
- Join Date
- Oct 2006
- Posts
- 7
I will try that. Thanks


