如果是登陆到远程smtp服务器上发送的话可以使用```perl

#!/usr/bin/perl -wuse Mail::Sender;
use strict;
printf("please input your passwd:\n");
system "stty -echo";
my $pass;
chomp($pass=);
system "stty echo";
my $sender= new Mail::Sender{smtp=> ‘smtp.126.com’,from=>’[email protected]’,auth=>’LOGIN’,authid=>’user’,authpwd=> $pass,debug=>’./perllog’};
$sender->MailMsg({to=>’[email protected]’,subject=>’perl send mail’,msg=>’中文测试’,debug=>’./perllog’}) or die "failed";
$sender->Close();
再提供一个可以发送附件的版本,直接使用内部的邮件服务器发送一些小文件。如果想使用远程服务器可以根据前面的脚本修改。#!/usr/bin/perl -wuse Mail::Sender;
my $txt;
$txt="hi,all :\n\t xxxx!";
&sendmsg($ARGV[0],$txt,$ARGV[1]);
sub sendmsg(){my $add=$_[0];
#email addressmy $msg="$_[1]";
#email txtmy $file=$_[2];
#fileopen my $LOG ,">/tmp/mail.log";
my $sender =new Mail::Sender{

$sender->MailFile({to=>$add,subject=>“hello”,msg=>"$msg",debug=>$LOG,file => $file,charset => ‘gb2312’}) or die “$Mail::Sender::Error\n”;close($LOG);$sender->Close;}