ZT文萃

          本博不原創,轉帖自己感興趣那些事人物,什么入眼貼什么,隨心所欲。
          posts - 93, comments - 5, trackbacks - 0, articles - 0
            BlogJava :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理

          在Bugzilla中通過SMTP發通知郵件

          Posted on 2013-09-27 18:40 ZT文萃 閱讀(3895) 評論(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窗口該怎么操作呢?
          主站蜘蛛池模板: 满城县| 嘉义县| 和田市| 肥城市| 都兰县| 河津市| 宁河县| 大兴区| 津南区| 靖州| 墨玉县| 柳州市| 大冶市| 万安县| 张北县| 峨眉山市| 临朐县| 密云县| 连州市| SHOW| 东明县| 曲麻莱县| 吴川市| 怀仁县| 武夷山市| 柞水县| 沙坪坝区| 米林县| 包头市| 乌兰察布市| 龙门县| 隆安县| 普定县| 定结县| 合水县| 昆明市| 巴南区| 沾化县| 永顺县| 桐庐县| 锡林浩特市|