ZT文萃

本博不原创,转帖自己感兴趣那些事人物,什么入眼贴什么,随心所欲。
posts - 93, comments - 5, trackbacks - 0, articles - 0
  BlogJava :: 首页 :: 新随笔 :: 联系 :: 聚合  :: 管理

在Bugzilla中通过SMTP发通知邮件

Posted on 2013-09-27 18:40 ZT文萃 阅读(3851) 评论(1)  编辑  收藏 所属分类: 中间件
From:
http://www.cnitblog.com/201/archive/2011/05/25/74069.html

在Bugzilla中通过SMTP发通知邮件
Posted on 2011/04/05 by admin

Bugzilla 4.0注册验证通知等邮件可以通过SendMail之类的来发送,配置也很简单,但是它发出去的邮件后缀地址是localhost.localdomain之类的地址,会被一些邮箱拦截,从而收不到邮件。所以通过SMTP来发邮件还是很必要的。
文档上说的配置SMTP也很简单,但是我在配置的时候遇到几个问题,在此记录下来
1、The new value for smtp_username is invalid: SMTP Authentication is not available. Run checksetup.pl for more details.
这是我在Bugzilla中Create New Account的时候发验证邮件时产生的,这个的原因是Perl有个模块没有安装,安装下就可以了
sudo perl install-module.pl Authen::SASL
自己先可以通过$ ./checksetup.pl –check-modules查看下已经安装了哪些模块
只要安装好,上述的这个问题就解决了

所以再次试着注册一个用户,提示邮件发送成功了,于是下面的问题产生了

2、提示邮件成功发送,但是实际邮件没有发送出去,因为我填的邮箱没有收到邮件
在这里我原先是开启了use_mailer_queue这个功能
于是我选择使用Test模式(Parameters -> Email -> mail_delivery_method -> SMTP)再发了一次,mailer.testfile木有邮件

网 络上有人和我是一样的问题,发不出去邮件,我参看这里http://hi.baidu.com/ever__love/blog/item /62473a9772800846d0135e2c.html的方法,把use_mailer_queue关闭(Parameters -> Email -> use_mailer_queue -> Off),再试着发送一次,果真mailer.testfile当中有邮件了

这样就基本定位到问题use_mailer_queue没有正常工作

于是又把use_mailer_queue开启
执行下面的命令
$ $BUGZILLA_HOME/jobqueue.pl check
Configuration looks okay
jobqueue.pl running – pid 5317
9 jobs in the queue.

看起来似乎正常,但是提示9 jobs in the queue,并且这个数目一直没有减少,这说明邮件几乎都被堵塞在这里了,而并没有发出去

于是又Debug发现
$ $BUGZILLA_HOME/jobqueue.pl -f -d restart
Killing 9657
Starting up…
TheSchwartz::work_once found no jobs
TheSchwartz::work_once found no jobs

几乎神了,这里又说没有错误,那到底是哪里出问题了呢?
目前无解,求解ING。。。

UPDATE 后来经过分析解决了此问题
虽然debug jobqueue出来的信息开头几个没有发现什么异常,但是经过很多个“TheSchwartz::work_once found no jobs”之后出来一些错误信息,如下:
……
TheSchwartz::work_once found no jobs
TheSchwartz::work_once found no jobs
TheSchwartz::work_once found no jobs
…….
TheSchwartz::work_once found no jobs
TheSchwartz::work_once found no jobs
TheSchwartz::work_once found no jobs
TheSchwartz::work_once got job of class ‘Bugzilla::Job::Mailer’
Working on Bugzilla::Job::Mailer …
Use of uninitialized value $hostname in concatenation (.) or string at Bugzilla/Mailer.pm line 153.
job failed. considering retry. is max_retries of 725 >= failures of 5?
job failed: There was an error sending mail from ‘bugzilla_admin@’ to
‘xxxxx@aol.com’:Can’t call method “address” on an undefined value at
lib/Email/Send/SMTP.pm line 25.
TheSchwartz::work_once found no jobs
……
TheSchwartz::work_once found no jobs
TheSchwartz::work_once got job of class ‘Bugzilla::Job::Mailer’
Working on Bugzilla::Job::Mailer …
Use of uninitialized value $hostname in concatenation (.) or string at Bugzilla/Mailer.pm line 153.
job failed. considering retry. is max_retries of 725 >= failures of 5?
job failed: There was an error sending mail from ‘bugzilla_admin@’ to
‘xxxxxx@gmail.com’:Can’t call method “address” on an undefined value
at lib/Email/Send/SMTP.pm line 25.
TheSchwartz::work_once found no jobs
……
TheSchwartz::work_once found no jobs

……是我省略掉了很多这样相同的状态

看起来这个jobqueue当中的任务不是立即就执行了的,它可能是经过某种算法才执行的
否则不应该出现第一个就是“TheSchwartz::work_once found no jobs”,到后面才有任务执行的

并且进一步发现这些任务队列都是放在数据库当中的一张表(ts_job)中的,任务成功一个就把它从这张表中删除

不过此时问题还没有解决,认真看下错误,并且看了指出的错误地方的源代码,觉得应该是mailfrom填错了,可能我这里填的不完整

又打开SMTP的调试开关(Parameters -> Email -> smtp_debug -> On),这样能看到更多的详细信息,基本觉得问题就在这了

于是我填写了标准的邮件格式“username@example.com”之后再试,邮件还不没有发出去,jobqueue的的数量又增加了一个,
看来可能前面的这些包含错误信息的队列已经将后面的阻塞了,于是我试着将ts_job表当中的数据删除
truncate table ts_job; // 反正我这里是直接truncate掉了的,我不知道这里delete和truncate有没有区别

再次注册了一遍,看到后台输出通知邮件发送成功的信息,如下:
TheSchwartz::work_once found no jobs
TheSchwartz::work_once got job of class ‘Bugzilla::Job::Mailer’
Working on Bugzilla::Job::Mailer …
Net::SMTP>>> Net::SMTP(2.31)
Net::SMTP>>> Net::Cmd(2.29)
Net::SMTP>>> Exporter(5.63)
Net::SMTP>>> IO::Socket::INET(1.31)
Net::SMTP>>> IO::Socket(1.31)
Net::SMTP>>> IO::Handle(1.28)
Net::SMTP=GLOB(0xb79ce68)<<< 220 esmtp4.qq.com Esmtp QQ Mail Server
Net::SMTP=GLOB(0xb79ce68)>>> EHLO localhost.localdomain
Net::SMTP=GLOB(0xb79ce68)<<< 250-esmtp4.qq.com
Net::SMTP=GLOB(0xb79ce68)<<< 250-PIPELINING
Net::SMTP=GLOB(0xb79ce68)<<< 250-SIZE 52428800
Net::SMTP=GLOB(0xb79ce68)<<< 250-AUTH LOGIN PLAIN
Net::SMTP=GLOB(0xb79ce68)<<< 250-AUTH=LOGIN
Net::SMTP=GLOB(0xb79ce68)<<< 250 8BITMIME
Net::SMTP=GLOB(0xb79ce68)>>> AUTH LOGIN
……
Net::SMTP=GLOB(0xb79ce68)<<< 235 Authentication successful
Net::SMTP=GLOB(0xb79ce68)>>> MAIL FROM:
Net::SMTP=GLOB(0xb79ce68)<<< 250 Ok
Net::SMTP=GLOB(0xb79ce68)>>> RCPT TO:
Net::SMTP=GLOB(0xb79ce68)<<< 250 Ok
Net::SMTP=GLOB(0xb79ce68)>>> DATA
Net::SMTP=GLOB(0xb79ce68)<<< 354 End data with .
Net::SMTP=GLOB(0xb79ce68)>>> From: xxxxxx@qq.com
Net::SMTP=GLOB(0xb79ce68)>>> To: xxxxxx@gmail.com
Net::SMTP=GLOB(0xb79ce68)>>> Subject: Bugzilla: confirm account creation
Net::SMTP=GLOB(0xb79ce68)>>> X-Bugzilla-Type: admin
Net::SMTP=GLOB(0xb79ce68)>>> X-Bugzilla-URL:
Net::SMTP=GLOB(0xb79ce68)>>> Auto-Submitted: auto-generated
Net::SMTP=GLOB(0xb79ce68)>>> Content-Type: text/plain; charset=”UTF-8″
Net::SMTP=GLOB(0xb79ce68)>>> MIME-Version: 1.0
Net::SMTP=GLOB(0xb79ce68)>>> Date: Tue, 05 Apr 2011 16:05:23 +0800
Net::SMTP=GLOB(0xb79ce68)>>>
Net::SMTP=GLOB(0xb79ce68)>>> Bugzilla has received a request to create a user account
Net::SMTP=GLOB(0xb79ce68)>>> using your email address (xxxxxx@gmail.com).
Net::SMTP=GLOB(0xb79ce68)>>>
Net::SMTP=GLOB(0xb79ce68)>>> To continue creating an account using this email address, visit the
Net::SMTP=GLOB(0xb79ce68)>>> following link by April 8, 2011 at 16:05 CST:
Net::SMTP=GLOB(0xb79ce68)>>>
Net::SMTP=GLOB(0xb79ce68)>>> token.cgi?t=FegLL6OpYM&a=request_new_account
Net::SMTP=GLOB(0xb79ce68)>>> PRIVACY NOTICE: Bugzilla is an open bug tracking system. Activity on most
Net::SMTP=GLOB(0xb79ce68)>>> bugs, including email addresses, will be visible to the public. We recommend
……
Net::SMTP=GLOB(0xb79ce68)>>> .
Net::SMTP=GLOB(0xb79ce68)<<< 250 Ok: queued as
Net::SMTP=GLOB(0xb79ce68)>>> QUIT
Net::SMTP=GLOB(0xb79ce68)<<< 221 Bye
job completed
TheSchwartz::work_once found no jobs

到QQ Mail也看到发送成功的邮件,在Gmail也收到了邮件,到此才算基本成功。

Parameters -> Email里面我的基本几项数据如下
mailfrom : xxxxxx@qq.com // 出现问题就是这里填的不标准
use_mailer_queue : on
smtpserver : smtp.qq.com
smtp_username : xxxxxx@qq.com
smtp_password : ******

如果mail_delivery_method你选择SendMail或者Test,那么SMTP相关的参数就可以不用填了,如果你是通过SSL加密的SMTP链接,应该是要新装插件了

P.S. 关于use_mailer_queue的信息请挪步http://www.bugzilla.org/releases/4.0/release-notes.html#v34_feat_async

评论

# re: 在Bugzilla中通过SMTP发通知邮件[未登录]  回复  更多评论   

2015-05-11 18:42 by young
试着将ts_job表当中的数据删除
truncate table ts_job
请问在cmd窗口该怎么操作呢?

只有注册用户登录后才能发表评论。


网站导航: