hi all,
i have written a shell-script which logs onto a mail-server using telnet and then tries to send the HELO command. The code for the same looks something like this:

exec telnet 150.236.18.66 25;
echo "HELO";

The problem is that though the telnet connection is established the "HELO" command doesn't get executed. Kindly let me know what to do to get the "HELO" command executed.

Thanks in advance.

subhash

telnet 150.236.18.66 25 <<EOF
HELO
whatever else you need to send the mail
EOF

Better yet, have the script write everything it wants to send in a file and do

telnet 150.236.18.66 25 <<filename

Or, even better, simply create a properly formatted mail message and use sendmail to send it.

But if i use the following code

telnet 150.236.18.66 25 <<EOF
HELO
whatever else you need to send the mail
EOF

then the telnet connection is getting closed before the HELO command is executed. Please help me out.

Well, it shouldn't be.

Using a "here document" is very standard for this sort of thing.

How do you know it is getting closed before sending that? (It's not something you'll see in the console, or anything.)

Edit: And the second example in my first post should be <filename, not <<filename.

It actually probably should be in most secure environments...

Try this one:

telnet $mailserver <<END
    user $USER $PWORD
   /path/to/HELO
    exit
END

set up the mailserver, USER and PWORD variables accordingly.
You usually need to authenticate with telnet.

Hey There,

You can also try HELO whateveryourdomainis.com and see if the mailserver isn't just dishing you for not identifying your origin.
or try EHLO ..etc, etc, etc and, like omrsafetyo mentioned, you'll probably need to authenticate.

Best wishes,

Mike


Maybe, maybe not.

But if i use the following code

telnet 150.236.18.66 25 <<EOF
HELO
whatever else you need to send the mail
EOF

then the telnet connection is getting closed before the HELO command is executed. Please help me out.

Hi,

I am not able to send the android commands through
telnet localhost portnumber
and then the command

The command is not getting executed..

I also tried using adb shell and then nc localhost port

but still cannot..

Can anyone please help.

Thanks in Anticipation!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.