Skip to content

Instantly share code, notes, and snippets.

@thinkhy
Last active August 29, 2015 13:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thinkhy/10473729 to your computer and use it in GitHub Desktop.
Save thinkhy/10473729 to your computer and use it in GitHub Desktop.
Test SMPT server
use strict;
use warnings;
use Net::SMTP;
my $smtpserver = 'mail.server.com';
my $smtpport = 25;
my $smtpuser = 'test';
my $smtppassword = 'test';
my $smtp = Net::SMTP->new($smtpserver, Port=>$smtpport, Timeout => 10, Debug => 1);
die "Could not connect to server!\n" unless $smtp;
$smtp->auth($smtpuser, $smtppassword);
$smtp->mail("lin");
$smtp->to("hello\@world.com");
$smtp->data();
$smtp->datasend("To: hello\@world.com\n");
$smtp->quit;
# OUTPUT:
#Net::SMTP>>> Net::SMTP(2.31)
#Net::SMTP>>> Net::Cmd(2.29)
#Net::SMTP>>> Exporter(5.64_01)
#Net::SMTP>>> IO::Socket::INET(1.31)
#Net::SMTP>>> IO::Socket(1.31)
#Net::SMTP>>> IO::Handle(1.28)
#Net::SMTP=GLOB(0x2be1e80)<<< 220 mail.server.com ESMTP Sendmail 8.14.4/8.14.4
#; Fri, 11 Apr 2014 19:48:30 +0800
#Net::SMTP=GLOB(0x2be1e80)>>> EHLO localhost.localdomain
#Net::SMTP=GLOB(0x2be1e80)<<< 250-mail.server.com Hello [9.10.10.236], please
#d to meet you
#Net::SMTP=GLOB(0x2be1e80)<<< 250-ENHANCEDSTATUSCODES
#Net::SMTP=GLOB(0x2be1e80)<<< 250-PIPELINING
#Net::SMTP=GLOB(0x2be1e80)<<< 250-8BITMIME
#Net::SMTP=GLOB(0x2be1e80)<<< 250-SIZE
#Net::SMTP=GLOB(0x2be1e80)<<< 250-DSN
#Net::SMTP=GLOB(0x2be1e80)<<< 250-ETRN
#Net::SMTP=GLOB(0x2be1e80)<<< 250-AUTH DIGEST-MD5 PLAIN
#Net::SMTP=GLOB(0x2be1e80)<<< 250-DELIVERBY
#Net::SMTP=GLOB(0x2be1e80)<<< 250 HELP
#Net::SMTP=GLOB(0x2be1e80)>>> AUTH DIGEST-MD5
#Net::SMTP=GLOB(0x2be1e80)<<< 334 bm9uY2U9IktIMmd6ek51YTVSMFcxS2lDM0h2MWcxSFRCSlc
#3VnV5VXB6MlBJeHY5TVE9IixyZWFsbT0iaHVhbmd5ZS5jbi5pYm0uY29tIixxb3A9ImF1dGgsYXV0aC1
#pbnQsYXV0aC1jb25mIixjaXBoZXI9InJjNC00MCxyYzQtNTYscmM0LGRlcywzZGVzIixtYXhidWY9ODE
#5MixjaGFyc2V0PXV0Zi04LGFsZ29yaXRobT1tZDUtc2Vzcw==
#Net::SMTP=GLOB(0x2be1e80)>>> YXV0aHppZD0idGVzdGNsb3VkIixjaGFyc2V0PXV0Zi04LGNpcGh
#lcj1yYzQsY25vbmNlPSJjNDRlMjFkZGUyYjkwMTI1NjViY2E1NzFmMmVjMGE4MyIsZGlnZXN0LXVyaT0
#ic210cC90b29sc2NlbnRlci5jbi5pYm0uY29tIixuYz0wMDAwMDAwMSxub25jZT0iS0gyZ3p6TnVhNVI
#wVzFLaUMzSHYxZzFIVEJKVzdWdXlVcHoyUEl4djlNUT0iLHFvcD1hdXRoLWNvbmYscmVhbG09Imh1YW5
#neWUuY24uaWJtLmNvbSIscmVzcG9uc2U9ODc3ZDY5Mzg5OTVhNWJjYzhkM2VlODc4NmFhMTdmZWYsdXN
#lcm5hbWU9InRlc3RjbG91ZCI=
#Net::SMTP=GLOB(0x2be1e80)<<< 334 cnNwYXV0aD1mNGQzNGU1YjE3YmRhMDQ0NWM3M2Q3MDU0YWU
#xODVhOA==
#Net::SMTP=GLOB(0x2be1e80)>>>
#Net::SMTP=GLOB(0x2be1e80)<<< 235 2.0.0 OK Authenticated
#Net::SMTP=GLOB(0x2be1e80)>>> MAIL FROM:<hello>
#Net::SMTP: Unexpected EOF on command channel at E:\tool\smtp.pl line 35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment