#!/usr/bin/perl-w
Use strict;
Use NET::SMTP;
Use AUTHEN::SASL (requires user authentication on the SMTP server, required module)
BEGIN {
Push (@INC, '/usr/lib/perl5/5.8.8/net/');
}
My $from = ' huashan125@huashan.peonymao.com ';
My $to = ' peonymao@orrisintl.com ';
My $username = ' huashan125 ';
My $passwd = ' huashan125 ';
My $subject = ' Test Email ';
My $smtp = net::smtp->new (' 192.168.21.82 ');
$smtp->auth ($username, $passwd) or die "could not authenticate $!"; (The order of the three sentences)
$SMTP->mail ($from);
$SMTP->to ($to);
$SMTP->data ();
$smtp->datasend ("From: $from/n");
$smtp->datasend ("to: $to/n");
# $SMTP->datasend ("Cc: $Cc/n");
$smtp->datasend ("Subject: $subject/n");
$SMTP->datasend ("This are a test Perl email/nit is successfull");
$SMTP->dataend ();
$SMTP->quit;
---------------------------------------------------The following are examples of your own writing--------------------------------------
#!/usr/bin/perl-w
Use NET::SMTP;
$SMTP = net::smtp->new (' 10.1.28.22 '); #邮件服务器地址
$smtp->mail (' zhang@163.com '); #发件人
$smtp->to (' zhang@sina.com '); #收件人
$smtp->to (' zhang@163.com ');
$SMTP->data ();
$smtp->datasend ("from:/" zhang/"<zhang/@163.com>/n");
$smtp->datasend ("To:/" zhang/"<zhang/@sina. com>,/n/" zhang/"<zhang/@163.com>,/n");
$smtp->datasend ("subject:monitor_prov/n/n"); #主题
My $my _url = ' http://127.0.0.1:8081/div.html '. "/n";
#my $my _url = ' <a href= ' http://127.0.0.1:8081/div.html ' >monitor_info</a><br> '. "/n";
$smtp->datasend ($my _url);
$smtp->datasend ("Test mail/n");
$smtp->dataend ();
$smtp->quit;