Does anybody know why mx1.hotmail.com doesn't response correctly? Thanks


M

mike

Hi Guys,

In command line, I tried to connect and read responses from hotmail's
smtp server, and get the ACK very fast, and correct. But, when I tried
to do the same work with a script, the response to "helo" was very
slow(30 seconds), and failed eventually. However, when I tried with
gmail's smtp server(and some others), the script worked fine.
Could anybody give me some hints what the problem is(please see
attached content)?

Thanks a lot.

Mike

-------------------------------------------------------------
In command line:

[testhost]$ telnet mx1.hotmail.com 25
Trying 65.54.244.136...
Connected to mx1.hotmail.com (65.54.244.136).
Escape character is '^]'.
220 bay0-mc3-f9.bay0.hotmail.com Sending unsolicited commercial or
bulk e-mail to Microsoft's computer network is prohibited. Other
restrictions are found at http://privacy.msn.com/Anti-spam/.
Violations will result in use of equipment located in California and
other states. Mon, 11 Jun 2007 12:59:17 -0700
helo testeasy.com
250 bay0-mc3-f9.bay0.hotmail.com (3.3.3.1) Hello [65.61.195.165]
quit
221 bay0-mc3-f9.bay0.hotmail.com Service closing transmission channel
Connection closed by foreign host.
[testhost]$

-------------------------------------------------------------

Run the test.pl with gmail's smtp server:

[testhost]$ test.pl gsmtp183.google.com
2007-05-11 13:01:24 << 220 mx.google.com ESMTP 34si1452943nfu
2007-05-11 13:01:24 >> helo testeasy.com
2007-05-11 13:01:24 waiting...
2007-05-11 13:01:24 << 250 mx.google.com at your service
2007-05-11 13:01:24 done
[testhost]$

-------------------------------------------------------------

Run the test.pl with hotmail's smtp server:

[testhost]$ test.pl mx1.hotmail.com
2007-05-11 13:01:56 << 220 bay0-mc12-f16.bay0.hotmail.com Sending
unsolicited commercial or bulk e-mail to Microsoft's computer network
is prohibited. Other restrictions are found at http://privacy.msn.com/Anti-spam/.
Violations will result in use of equipment located in California and
other states. Mon, 11 Jun 2007 13:01:19 -0700
2007-05-11 13:01:56 >> helo testeasy.com
2007-05-11 13:01:56 waiting...
2007-05-11 13:02:26 << NOTHING
2007-05-11 13:02:26 done
[testhost]$

-------------------------------------------------------------

Source code of test.pl

#!/usr/bin/perl -w

use strict;
use IO::Socket;
use Time::HiRes qw( usleep ualarm gettimeofday tv_interval );

my ($string, $ret, $outstr);

my $s = new IO::Socket::INET(PeerAddr=>$ARGV[0],
PeerPort=> 25,
Proto => 'tcp',
Timeout => 10);
die "Could not create socket: $!\n" unless $s;

select($s);
$|=1;
select(STDOUT);

$ret = $s->sysread( $string, 4096);
&prtlog("<< $string");

$string = "helo testeasy.com\n";
$ret = $s->syswrite($string);
if ($ret != length($string)) {
prtlog("syswrite error. $ret\n");
close($s);
exit(0);
}
&prtlog(">> $string");

$string = '';
&prtlog("waiting...\n");

$ret = $s->sysread( $string, 4096);
if ($string eq '') {
&prtlog("<< NOTHING\n");
}
else {
&prtlog("<< $string");
}

close($s);

prtlog("done\n");


sub get_date()
{
my @months = qw(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov
Dec);
my ($second, $minute, $hour, $dayOfMonth, $month, $yearOffset,
$dayOfWeek, $dayOfYear, $daylightSavings) = localtime();
my $year = 1900 + $yearOffset;
return sprintf("%d-%02d-%02d %02d:%02d:%02d", $year, $month,
$dayOfMonth, $hour, $minute, $second);
}

sub prtlog {
my $str = shift;

print &get_date." $str";
}
 
Ad

Advertisements

R

Randal L. Schwartz

mike> In command line, I tried to connect and read responses from hotmail's
mike> smtp server, and get the ACK very fast, and correct. But, when I tried
mike> to do the same work with a script, the response to "helo" was very
mike> slow(30 seconds), and failed eventually. However, when I tried with
mike> gmail's smtp server(and some others), the script worked fine.
mike> Could anybody give me some hints what the problem is(please see
mike> attached content)?

Why are you writing your own tool instead of using Net::SMTP or any of the
higher-level libraries?

And why do you care if the ACK is fast or slow?

Unless you're a spammer... in which case... FOAD.

print "Just another Perl hacker,"; # the original
 
M

mike

mike> In command line, I tried to connect and read responses from hotmail's
mike> smtp server, and get the ACK very fast, and correct. But, when I tried
mike> to do the same work with a script, the response to "helo" was very
mike> slow(30 seconds), and failed eventually. However, when I tried with
mike> gmail's smtp server(and some others), the script worked fine.
mike> Could anybody give me some hints what the problem is(please see
mike> attached content)?

Why are you writing your own tool instead of using Net::SMTP or any of the
higher-level libraries?

And why do you care if the ACK is fast or slow?

Unless you're a spammer... in which case... FOAD.

print "Just another Perl hacker,"; # the original

--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<[email protected]> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!

Dude, I create the lower level code doesn't mean I am a hacker. Have
you ever seen a hacker asked this such low lever questions? :)
 
T

Tad McClellan

mike said:
#!/usr/bin/perl -w

use strict;


That should be:

#!/usr/bin/perl

use warnings;
use strict;

&prtlog("<< $string");


You should not use the ampersand on subroutine calls unless what
it means is what you really want to do (and it seldom is).

prtlog("syswrite error. $ret\n");


That's better.

&prtlog(">> $string");

&prtlog("<< NOTHING\n");
&prtlog("<< $string");


Oops, slipped back to bad style.

prtlog("done\n");


Followed by a return to good style.

You should choose one style and stick with it.


my @months = qw(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov
Dec);


You never use the @months array. So why is it there?

my ($second, $minute, $hour, $dayOfMonth, $month, $yearOffset,
$dayOfWeek, $dayOfYear, $daylightSavings) = localtime();
my $year = 1900 + $yearOffset;
return sprintf("%d-%02d-%02d %02d:%02d:%02d", $year, $month,
$dayOfMonth, $hour, $minute, $second);


You got the year value right. :)

You got the month value wrong. :-(

print &get_date." $str";


print get_date() . " $str";
 
M

mike

mike> In command line, I tried to connect and read responses from hotmail's
mike> smtp server, and get the ACK very fast, and correct. But, when I tried
mike> to do the same work with a script, the response to "helo" was very
mike> slow(30 seconds), and failed eventually. However, when I tried with
mike> gmail's smtp server(and some others), the script worked fine.
mike> Could anybody give me some hints what the problem is(please see
mike> attached content)?

Why are you writing your own tool instead of using Net::SMTP or any of the
higher-level libraries?

And why do you care if the ACK is fast or slow?

Unless you're a spammer... in which case... FOAD.

print "Just another Perl hacker,"; # the original

--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<[email protected]> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!

Actually, I just found that hotmail.com sucks. Once I append "\r\n" to
the end of the string, then everything worked fine.
 
R

Randal L. Schwartz

mike> Actually, I just found that hotmail.com sucks. Once I append "\r\n" to
mike> the end of the string, then everything worked fine.

No, that means you "suck" as a programmer. The SMTP protocol officially
requires \cM\cJ.

This is why I said you shouldn't be writing this code from scratch!

Sigh. Kids.
 
Ad

Advertisements

M

mike

mike> Actually, I just found that hotmail.com sucks. Once I append "\r\n" to
mike> the end of the string, then everything worked fine.

No, that means you "suck" as a programmer. The SMTP protocol officially
requires \cM\cJ.

This is why I said you shouldn't be writing this code from scratch!

Sigh. Kids.

--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<[email protected]> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!

Thanks for correcting,dude
 
Ad

Advertisements


Top