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";
}
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";
}