Posted on 2013-09-27 18:40
ZT文萃 閱讀(3906)
評(píng)論(1) 編輯 收藏 所屬分類(lèi):
中間件
From:
http://www.cnitblog.com/201/archive/2011/05/25/74069.html
在Bugzilla中通過(guò)SMTP發(fā)通知郵件
Posted on 2011/04/05 by admin
Bugzilla 4.0注冊(cè)驗(yàn)證通知等郵件可以通過(guò)SendMail之類(lèi)的來(lái)發(fā)送,配置也很簡(jiǎn)單,但是它發(fā)出去的郵件后綴地址是localhost.localdomain之類(lèi)的地址,會(huì)被一些郵箱攔截,從而收不到郵件。所以通過(guò)SMTP來(lái)發(fā)郵件還是很必要的。
文檔上說(shuō)的配置SMTP也很簡(jiǎn)單,但是我在配置的時(shí)候遇到幾個(gè)問(wèn)題,在此記錄下來(lái)
1、The new value for smtp_username is invalid: SMTP Authentication is not available. Run checksetup.pl for more details.
這是我在Bugzilla中Create New Account的時(shí)候發(fā)驗(yàn)證郵件時(shí)產(chǎn)生的,這個(gè)的原因是Perl有個(gè)模塊沒(méi)有安裝,安裝下就可以了
sudo perl install-module.pl Authen::SASL
自己先可以通過(guò)$ ./checksetup.pl –check-modules查看下已經(jīng)安裝了哪些模塊
只要安裝好,上述的這個(gè)問(wèn)題就解決了
所以再次試著注冊(cè)一個(gè)用戶,提示郵件發(fā)送成功了,于是下面的問(wèn)題產(chǎn)生了
2、提示郵件成功發(fā)送,但是實(shí)際郵件沒(méi)有發(fā)送出去,因?yàn)槲姨畹泥]箱沒(méi)有收到郵件
在這里我原先是開(kāi)啟了use_mailer_queue這個(gè)功能
于是我選擇使用Test模式(Parameters -> Email -> mail_delivery_method -> SMTP)再發(fā)了一次,mailer.testfile木有郵件
網(wǎng) 絡(luò)上有人和我是一樣的問(wèn)題,發(fā)不出去郵件,我參看這里http://hi.baidu.com/ever__love/blog/item /62473a9772800846d0135e2c.html的方法,把use_mailer_queue關(guān)閉(Parameters -> Email -> use_mailer_queue -> Off),再試著發(fā)送一次,果真mailer.testfile當(dāng)中有郵件了
這樣就基本定位到問(wèn)題use_mailer_queue沒(méi)有正常工作
于是又把use_mailer_queue開(kāi)啟
執(zhí)行下面的命令
$ $BUGZILLA_HOME/jobqueue.pl check
Configuration looks okay
jobqueue.pl running – pid 5317
9 jobs in the queue.
看起來(lái)似乎正常,但是提示9 jobs in the queue,并且這個(gè)數(shù)目一直沒(méi)有減少,這說(shuō)明郵件幾乎都被堵塞在這里了,而并沒(méi)有發(fā)出去
于是又Debug發(fā)現(xiàn)
$ $BUGZILLA_HOME/jobqueue.pl -f -d restart
Killing 9657
Starting up…
TheSchwartz::work_once found no jobs
TheSchwartz::work_once found no jobs
幾乎神了,這里又說(shuō)沒(méi)有錯(cuò)誤,那到底是哪里出問(wèn)題了呢?
目前無(wú)解,求解ING。。。
UPDATE 后來(lái)經(jīng)過(guò)分析解決了此問(wèn)題
雖然debug jobqueue出來(lái)的信息開(kāi)頭幾個(gè)沒(méi)有發(fā)現(xiàn)什么異常,但是經(jīng)過(guò)很多個(gè)“TheSchwartz::work_once found no jobs”之后出來(lái)一些錯(cuò)誤信息,如下:
……
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
……是我省略掉了很多這樣相同的狀態(tài)
看起來(lái)這個(gè)jobqueue當(dāng)中的任務(wù)不是立即就執(zhí)行了的,它可能是經(jīng)過(guò)某種算法才執(zhí)行的
否則不應(yīng)該出現(xiàn)第一個(gè)就是“TheSchwartz::work_once found no jobs”,到后面才有任務(wù)執(zhí)行的
并且進(jìn)一步發(fā)現(xiàn)這些任務(wù)隊(duì)列都是放在數(shù)據(jù)庫(kù)當(dāng)中的一張表(ts_job)中的,任務(wù)成功一個(gè)就把它從這張表中刪除
不過(guò)此時(shí)問(wèn)題還沒(méi)有解決,認(rèn)真看下錯(cuò)誤,并且看了指出的錯(cuò)誤地方的源代碼,覺(jué)得應(yīng)該是mailfrom填錯(cuò)了,可能我這里填的不完整
又打開(kāi)SMTP的調(diào)試開(kāi)關(guān)(Parameters -> Email -> smtp_debug -> On),這樣能看到更多的詳細(xì)信息,基本覺(jué)得問(wèn)題就在這了
于是我填寫(xiě)了標(biāo)準(zhǔn)的郵件格式“username@example.com”之后再試,郵件還不沒(méi)有發(fā)出去,jobqueue的的數(shù)量又增加了一個(gè),
看來(lái)可能前面的這些包含錯(cuò)誤信息的隊(duì)列已經(jīng)將后面的阻塞了,于是我試著將ts_job表當(dāng)中的數(shù)據(jù)刪除
truncate table ts_job; // 反正我這里是直接truncate掉了的,我不知道這里delete和truncate有沒(méi)有區(qū)別
再次注冊(cè)了一遍,看到后臺(tái)輸出通知郵件發(fā)送成功的信息,如下:
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也看到發(fā)送成功的郵件,在Gmail也收到了郵件,到此才算基本成功。
Parameters -> Email里面我的基本幾項(xiàng)數(shù)據(jù)如下
mailfrom : xxxxxx@qq.com // 出現(xiàn)問(wèn)題就是這里填的不標(biāo)準(zhǔn)
use_mailer_queue : on
smtpserver : smtp.qq.com
smtp_username : xxxxxx@qq.com
smtp_password : ******
如果mail_delivery_method你選擇SendMail或者Test,那么SMTP相關(guān)的參數(shù)就可以不用填了,如果你是通過(guò)SSL加密的SMTP鏈接,應(yīng)該是要新裝插件了
P.S. 關(guān)于use_mailer_queue的信息請(qǐng)挪步http://www.bugzilla.org/releases/4.0/release-notes.html#v34_feat_async