- 论坛徽章:
- 0
|
发送邮件代码如下:
1 #!/usr/bin/perl
2 use strict;
3 use IO::Socket;
4 use Net::SMTP;
5 #use Authen::SASL;
6 my @emails = qw( xxx@xxx.com );
7 #my @warns = qw( aaaaaaaaaaaaa );
8 my $mtahost = 'smtp.xxx.com';
9 #my $mtahost = 'xx.xx.xxx.xxx';
10 my $mtaport = xxx;
11 #my $mtaport = 25;
12 my $user = 'xxx';
13 my $passwd = 'xxx';
14 print "kkkkkkkkkkk";
15 sub sendmail
16 {
17 my $msg = shift;
18 return unless @emails;
19 my $smtp = Net::SMTP->new('Host'=>$mtahost,'Port'=>$mtaport,Debug=>1);
20 #$smtp->auth($user,$passwd);
21 $smtp->auth('LOGIN',$user,$passwd);
22 if(defined $smtp)
23 {
24 print ("aaaaaaaaaaaaaa" ;
25 $smtp->mail("xxx\@xxx.com" ;
26 #$smtp->recipient(@emails);
27 $smtp->recipient("xxx\@xxx.com" ;
28 $smtp->data();
29 $smtp->datasend("From: Server Monitor <monitor\@sample-inc.com>\n" ;
30 $smtp->datasend("To: SA Team <sa\@sample-inc.com>\n" ;
31 $smtp->datasend("Subject: Server Warnings\n" ;
32
33 $smtp->datasend("\n" ;
34 for (@$msg) {
35 $smtp->datasend("$_\n" ;
36 }
37 $smtp->dataend();
38 $smtp->quit;
39 } else {
40 warn("[WARN] Can't connect to SMTP host\n" ;
41 }
42 }
43
44 sendmail();
调试日志信息
Net::SMTP>>> Net::SMTP(2.31)
Net::SMTP>>> Net::Cmd(2.29)
Net::SMTP>>> Exporter(5.5
Net::SMTP>>> IO::Socket::INET(1.29)
Net::SMTP>>> IO::Socket(1.29)
Net::SMTP>>> IO::Handle(1.25)
Net::SMTP=GLOB(0xafda9e0)<<< 220 smtp.xxx.com Microsoft ESMTP MAIL Service ready at Fri, 11 May 2012 08:53:35 +0800
Net::SMTP=GLOB(0xafda9e0)>>> EHLO localhost.localdomain
Net::SMTP=GLOB(0xafda9e0)<<< 250-smtp.xxx.com Hello [xx.xx.xxx.xxx]
Net::SMTP=GLOB(0xafda9e0)<<< 250-SIZE 10485760
Net::SMTP=GLOB(0xafda9e0)<<< 250-PIPELINING
Net::SMTP=GLOB(0xafda9e0)<<< 250-DSN
Net::SMTP=GLOB(0xafda9e0)<<< 250-ENHANCEDSTATUSCODES
Net::SMTP=GLOB(0xafda9e0)<<< 250-STARTTLS
Net::SMTP=GLOB(0xafda9e0)<<< 250-AUTH GSSAPI NTLM
Net::SMTP=GLOB(0xafda9e0)<<< 250-8BITMIME
Net::SMTP=GLOB(0xafda9e0)<<< 250-BINARYMIME
Net::SMTP=GLOB(0xafda9e0)<<< 250 CHUNKING
Net::SMTP=GLOB(0xafda9e0)>>> AUTH GSSAPI
Net::SMTP=GLOB(0xafda9e0)<<< 334 GSSAPI supported
Net::SMTP=GLOB(0xafda9e0)>>>
Net::SMTP=GLOB(0xafda9e0)<<< 334 YHYGBisGAQUFAqBsMGqgPDA6BgorBgEEAYI3AgIeBgkqhkiC9xIBAgIGCSqGSIb3EgECAgYKKoZIhvcSAQICAwYKKwYBBAGCNwICCqMqMCigJhskbm90X2RlZmluZWRfaW5fUkZDNDE3OEBwbGVhc2VfaWdub3Jl
Net::SMTP=GLOB(0xafda9e0)>>>
Net::SMTP=GLOB(0xafda9e0)<<< 535 5.7.3 Authentication unsuccessful
Net::SMTP=GLOB(0xafda9e0)>>> MAIL FROM:<xxx@xxx.com>
Net::SMTP=GLOB(0xafda9e0)<<< 530 5.7.1 Client was not authenticated
Net::SMTP=GLOB(0xafda9e0)>>> RCPT TO:<xxx@xxx.com>
Net::SMTP: Unexpected EOF on command channel at sendmail2 line 27
Authen::SASL
make
Skip blib/lib/Authen/SASL.pm (unchanged)
Skip blib/lib/Authen/SASL/EXTERNAL.pm (unchanged)
Skip blib/lib/Authen/SASL/CRAM_MD5.pm (unchanged)
Skip blib/lib/Authen/SASL/Perl/EXTERNAL.pm (unchanged)
Skip blib/lib/Authen/SASL/Perl/LOGIN.pm (unchanged)
Skip blib/lib/Authen/SASL/Perl/ANONYMOUS.pm (unchanged)
Skip blib/lib/Authen/SASL/Perl/PLAIN.pm (unchanged)
Skip blib/lib/Authen/SASL/Perl.pod (unchanged)
Skip blib/lib/Authen/SASL/Perl/DIGEST_MD5.pm (unchanged)
Skip blib/lib/Authen/SASL/Perl/CRAM_MD5.pm (unchanged)
Skip blib/lib/Authen/SASL/Perl.pm (unchanged)
Skip blib/lib/Authen/SASL.pod (unchanged)
Skip blib/lib/Authen/SASL/Perl/GSSAPI.pm (unchanged)
Manifying blib/man3/Authen::SASL: erl::LOGIN.3pm
lib/Authen/SASL/Perl/LOGIN.pm:175: Unknown command paragraph "=over4"
lib/Authen/SASL/Perl/LOGIN.pm:186: Unmatched =back
Manifying blib/man3/Authen::SASL: erl::EXTERNAL.3pm
Manifying blib/man3/Authen::SASL: erl::ANONYMOUS.3pm
Manifying blib/man3/Authen::SASL: erl: LAIN.3pm
lib/Authen/SASL/Perl/PLAIN.pm:146: Unknown command paragraph "=over4"
lib/Authen/SASL/Perl/PLAIN.pm:153: Unmatched =back
Manifying blib/man3/Authen::SASL: erl: IGEST_MD5.3pm
lib/Authen/SASL/Perl/DIGEST_MD5.pm:805: Unknown command paragraph "=over4"
lib/Authen/SASL/Perl/DIGEST_MD5.pm:815: Unmatched =back
Manifying blib/man3/Authen::SASL: erl.3pm
Manifying blib/man3/Authen::SASL: erl::CRAM_MD5.3pm
Manifying blib/man3/Authen::SASL.3pm
Manifying blib/man3/Authen::SASL: erl::GSSAPI.3pm
make test
PERL_DL_NONLAZY=1 /usr/bin/perl "-MExtUtils::Command::MM" "-e" "test_harness(0, 'inc', 'blib/lib', 'blib/arch')" t/*.t t/negotiations/*.t t/server/*.t
t/anon.......................ok
t/callback...................ok
t/cram_md5...................ok
t/digest_md5.................ok
t/digest_md5_verified........ok
t/external...................ok
t/login......................ok
t/negotiations/digest_md5....ok
t/negotiations/login.........ok
t/negotiations/plain.........ok
t/order......................ok
t/plain......................ok
t/server/digest_md5..........ok
10/33 skipped: various reasons
t/server/login..............."my" variable $cb masks earlier declaration in same scope at t/server/login.t line 75.
t/server/login...............ok
t/server/plain...............ok
All tests successful, 10 subtests skipped.
Files=15, Tests=313, 0 wallclock secs ( 0.29 cusr + 0.08 csys = 0.37 CPU)
make install
Appending installation info to /usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi/perllocal.pod |
|