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 ($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";
$smtp->mail('yuandan@XXX.com');#from person
$smtp->to($person); #...........person.........
$smtp->data();
$smtp->datasend($msg); #...........msg.........
$smtp->dataend();
$smtp->quit;
}
}作者: swaiwai 时间: 2010-7-13 17:39
UP学习作者: 在此间 时间: 2010-7-14 16:41
哈哈,问题解决了!还是开发人员帮忙解决的,代码改后如下:
sub MessageToMTA ($;$) {
my ($msg, $rcpt_to) = (@_);
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