|
我今天刚解决这个问题
打开...\Bugzilla\Mailer.pm, 修改如下MessageToMTA子程序
sub MessageToMTA {
my ($msg) = (@_);
#return if (Param('mail_delivery_method') eq "none");
my ($header, $body) = $msg =~ /(.*?\n)\n(.*)/s ? ($1, $2) : ('', $msg);
my $headers;
if ((!is_7bit_clean($header) or !is_7bit_clean($body))) {
($headers, $body) = encode_message($msg);
} else {
my @header_lines = split(/\n/, $header);
$headers = new Mail::Header \@header_lines, Modify => 0;
}
# Use trim to remove any whitespace (incl. newlines)
my $rcpt_to = trim($headers->get('to'));
use Net::SMTP;
my $smtp_server = 'smtp.163.com';
my $smtp_user = 'test@163.com';
my $smtp_pass = '123456';
my $encode_smtpuser = trim(encode_base64($smtp_user));
my $encode_smtppass = trim(encode_base64($smtp_pass));
my $smtp = Net::SMTP->new($smtp_server,Timeout => 60) ||
die 'Cannot connect to smtp server';
my $result = $smtp->command('AUTH','LOGIN');
my $answer = $smtp->getline();
# 334 VXNlcm5hbWU6
$result = $smtp->command($encode_smtpuser);
$answer = $smtp->getline();
# 334 UGFzc3dvcmQ6
$result = $smtp->command($encode_smtppass);
$answer = $smtp->getline();
# 235 Authentication successful
# or 535 Authentication failed
if ($answer =~ /535/i)
{print "Sorry,Authentication failed!n";exit;}
$smtp->mail($smtp_user);
$smtp->to($rcpt_to);
$smtp->data();
$smtp->datasend($msg);
$smtp->dataend();
$smtp->quit;
}
注意:我把涉及到Param方法的都注释了,因为运行时报错,无法调用。
可参考http://blog.chinaunix.net/u1/42969/showart_342667.html
http://dev.csdn.net/article/49/49481.shtm
http://www.blogjava.net/andyhan/archive/2005/07/13/7594.html |
|