|
3#
楼主 |
发表于 2010-7-14 16:41:36
|
只看该作者
哈哈,问题解决了!还是开发人员帮忙解决的,代码改后如下:
sub MessageToMTA ($;$) {
my ($msg, $rcpt_to) = (@_);
my $sendmailparam = "";
unless (Param("sendmailnow")) {
$sendmailparam = "-ODeliveryMode=deferred";
}
if ($enableSendMail == 1) {
# open(SENDMAIL, "|/usr/lib/sendmail $sendmailparam -t -i") ||
# die "Can't open sendmail";
#
# print SENDMAIL trim($msg) . "\n";
# close SENDMAIL;
#add for send mail
use Net::SMTP;
my $smtp_server = '192.168.10.2';
my $smtp_user = 'yuandan@XXX.com';
my $smtp_pass = 'yuandan';
#my $encode_smtpuser = trim(encode_base64($smtp_user));
#my $encode_smtppass = trim(encode_base64($smtp_pass));
my ($msg, $person) = (@_);
# Use die on error, so that the mail will be in the 'unsent mails' and
# can be sent from the sanity check page.
my $smtp = Net::SMTP->new($smtp_server) ||
die 'Cannot connect to server \'$smtp_server\'';
# auth sender, XXXbugs is the mailbox used as bugzilla daemon.
#$smtp->auth('yuandan', 'yuandan') or die "auth error\n";
my $result = $smtp->command('AUTH','LOGIN');
my $answer = $smtp->getline();
# 334 VXNlcm5hbWU6
$result = $smtp->command($smtp_user);
$answer = $smtp->getline();
# 334 UGFzc3dvcmQ6
$result = $smtp->command($smtp_pass);
$answer = $smtp->getline();
# 235 Authentication successful
# or 535 Authentication failed
if ($answer =~ /535/i)
{print "Sorry,Authentication failed!n";exit;}
$smtp->mail('yuandan@XXX.com');#from person
$smtp->to($person); #...........person.........
$smtp->data();
$smtp->datasend($msg); #...........msg.........
$smtp->dataend();
$smtp->quit;
}
} |
|