让bugzilla(2.20.1版本)使用第三方SMTP发邮件
Update:新增加让bugzilla(2.22.2版本)使用第三方SMTP发邮件 (2007-03-08)
前两天安装了最新的Bugzilla2.20.1,自身已经支持使用SMTP发送邮件,不再死靠着sendmail了,但是只支持非授权方式的SMTP,:(
参考2.18 版本的方法,终于搞定了2.20版本的授权方式的SMTP发送。
具体做法:
1.安装好bugzilla(具体如何安装,见其他相关文档)
2.修改$Bugzilla_DIR/defparams.pl,在@param_list中加入:
name => 'mailserver',
desc => 'Mail-Server',
type => 't',
default => 'mx.hit.edu.cn'
},
{
name => 'mailuser',
desc => 'Mail-User',
type => 't',
default => 'hdpan@hit.edu.cn'
},
{
name => 'mailpass',
desc => 'Mail-Pass',
type => 't',
default => 'xxxxxx'
},
注:修改后,删除$Bugzilla_DIR/data/下面的东西,重新运行$Bugzilla_DIR/checksetup.pl ,参数才可以生效。
3.修改$Bugzilla_DIR/Bugzilla/BugMail.pm,增加新的方法:
需要在文件头部加入引用:
{
my ($msg,$rcpt_to) = @_;
use Net::SMTP;
my $smtp_server = Param("mailserver");
my $smtp_user = Param("mailuser");
my $smtp_pass = Param("mailpass");
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 "Soryy,Authentication failed!n";exit;}
$smtp->mail($smtp_user);
$smtp->to($rcpt_to);
$smtp->data();
$smtp->datasend($msg);
$smtp->dataend();
$smtp->quit;
}
4.修改$Bugzilla_DIR/Bugzilla/BugMail.pm,使用新方法发邮件:
MessageToMTA_NEW($msg, $user->email);
5.OVER。
Update:
对$encode_smtpuser和$encode_smtppass增加了trim操作,发现encode_base64()有时候会在字符串结尾加了个空格。– 2006-04-28 11:30
Update:对这个错误:undef error - Goto undefined subroutine &main::encode_base64 at Bugzilla/BugMail.pm line …
改正办法是:将use MIME::Base64;放到后面定义,例如:
package Bugzilla::BugMail;
use base qw(Exporter);
@Bugzilla::BugMail::EXPORT = qw(
PerformSubsts
);
use Bugzilla::Constants;
use Bugzilla::Config qw(:DEFAULT $datadir);
use Bugzilla::Util;
use Bugzilla::User;
use Mail::Mailer;
use Mail::Header;
use MIME::Base64;
– 2006-05-30 16:30
[@more@]
帮帮忙
为什么我配置了以后,注册用户和修改密码可以收到信,但是新建bug就发不了信了,报Soryy,Authentication failed!n。老大帮帮
SMTP验证失败
注册用户修改密码新建bug应该是调用同一段邮件发送程序的。
不太清楚原因,可以在新建bug的时候用打印的方式调试一下上面发信的那段程序。
name => ‘mailserver’,
desc => ‘Mail-Server’,
type => ‘t’,
default => ‘mx.hit.edu.cn’
这个里面“default => ‘mx.hit.edu.cn’”我应该添smtp还是应该添pop,还是添域名?
填smtp,呵呵
可怜还是不行,只能给自己邮箱的用户发注册和修改密码,象163。263等都收不到信,呵呵
这个有可能是163、263这样的邮箱拒收你的smtp服务器发的信,你可以向gmail发信测试一下,我发现gmail很少会拒信。
还是不行
我按照你的改了,可是new account和修改bug的时候都提示下面的错误:
Software error:
Bad file descriptor at c:/Perl/site/lib/Mail/Mailer.pm line 285.
For help, please send mail to this site’s webmaster, giving this error message and the time and date of the error.
[Mon Apr 24 17:58:12 2006] token.cgi: Bad file descriptor at c:/Perl/site/lib/Mail/Mailer.pm line 285
这是为什么?
c:/Perl/site/lib/Mail/Mailer.pm line 285
这行是什么东西?
方便的话,msn联系:
MSN:panhaidong@hotmail.com
我的也出现过这个问题,但大部分是Soryy,Authentication failed!n
系统设置里面的2个项
mail_delivery_method:sendmail
和
smtpserver:localhost
如果不改成
mail_delivery_method:smtp
smtpserver: mail.chinacache.com(我服务器的)
我就还是用sendmail发信,如果改一个,就会报Software error:
Invalid argument at /usr/lib/perl5/site_perl/5.8.5/Mail/Mailer.pm line 285.
For help, please send mail to the webmaster (root@localhost), giving this error message and the time and date of the error.
如果都改了,就用新方法发信,但是改bug和新加bug无法收到信
我加你msn了
我叫linda(tinnaglncutlab504@hotmail.com)
如下
if(defined $exe)
{ # Fork and start a mailer
my $child = open $self, ‘|-’;
defined $child or die “Failed to send: $!”;
if($child==0)
{ # Child process will handle sending, but this is not real exec()
# this is a setup!!!
unless($self->exec($exe, $args, @to))
{ warn $!; # setup failed
_exit(1); # no DESTROY(), keep it for parent
}
}
}
else
{ $self->exec($exe, $args, @to) #【这就是285行】
or die $!;
}
在队长的帮助下,原因找到了,是要把
my $encode_smtpuser = encode_base64($smtp_user);
my $encode_smtppass = encode_base64($smtp_pass);
这2行改一下
my $encode_smtpuser = trim(encode_base64($smtp_user));
my $encode_smtppass = trim(encode_base64($smtp_pass));
愿意是经过base64编码后,加了空格,再次感谢队长,其他兄弟可以试试
队长,请帮忙
修改后提示以下错误:undef error - Goto undefined subroutine &main::encode_base64 at Bugzilla/BugMail.pm line 120.
120行:
goto &$AUTOLOAD;
谢谢!
不用,搞定了,谢谢!
undef error - Goto undefined subroutine &main::encode_base64 at Bugzilla/BugMail.pm line 120.
undef error - Goto undefined subroutine &main::encode_base64 at Bugzilla/BugMail.pm line 120.我也出现同样的错误!请问你是怎么解决的,谢谢!!!!
login
你好, 我装好之后,发现在mainpage上无法login, 输入用户名和密码后登录,就显示无法打开网页了,但是如果从add a new bug等类似的非mainpage的页面下,就能正常登录了
请问怎么会这样呐??谢谢!!
SOS
我的也出现过这个问题,修改BUG状态的时候出Soryy,Authentication failed!n
新增用户的时候没有给那个用户发邮件,怎么回事?
帮帮忙吧。
我的问题更搞笑
可以将新增和修改BUG的信息通过现在这种方式发出EMAIL并收到,但注册新的用户和修改密码却不可以.
总是535错误
会是哪里出了问题。
@bill:
535错误就是授权失败,可以先试用Telnet的方式测试SMTP状态:
http://search.csdn.net/c/blog.csdn.net/cjjky/archive/2007/02/23/1513083.aspx
undef error - Goto undefined subroutine &main::MessageToMTA_NEW at Bugzilla/BugMail.pm line 118.
内部错误
Bugzilla出现内部错误。请保存本页面,连同你的操作描述一起发给THE MAINTAINER HAS NOT YET BEEN SET。
URL: http://bugzilla.iem.ac.cn/process_bug.cgi
undef error - Goto undefined subroutine &main::MessageToMTA_NEW at Bugzilla/BugMail.pm line 118.
hello
我看有文章里说要修改defparams.pl这个文件的内容,可是我的bugzilla文件夹下并没有这个文件啊,请问这可能是什么原因呢?
注册新用户收不到信。
注册一个新用户,提示成功,但却收不到信,这是怎莫回事呢?
谢谢啦。
我在rd el5.0下安装的bugzilla2.22.7,也没找到defparams.pl,是什么原回呢?提交bug成功但会提示内部错误,邮件发不到。