mantisBT 无法接收到邮件通知问题解决 【Solve mantis can't receive Email notification 】

时间:2022-08-30 15:58:18

最近发现在使用的mantisBT 1.2.7不能接收邮件通知了, 随检查测试下,果不其然,mantis的提示都很正常,就是收不到邮件,一直都是可以的,真是很是奇怪,于是就有了下面的事情,

1 、查看配置文件config_inc.php和config_defaults_inc.php主要是涉及SMTP配的

<?php

        $g_enable_email_notification = ON;
        $g_smtp_host = 'smtp.domain.com';
        $g_smtp_usename = 'mantis@domain.com';
        $g_smtp_password = 'password';
        $g_phpMail_method = PHPMAILER_METHOD_SMTP;  使用PHPMailer
        $g_return_path_email = ‘mantis@domain.com'; 
        $g_from_email = 'mantis@domain.com';        必须和登录smtp server的帐号一直,不然有些邮件服务器的配置问题会拒绝,
?>

2、使用PHPMailer做测试 (/var/www/html/mantis/library/phpmailer/)

里面有README可以参考,下面是我的测试文件内容。

<?php
        require 'class.phpmailer.php';
        $mail = new PHPMailer;
        $mail->IsSMTP();
        $mail->SMTPDebug = 1;   //open debug mode, you can see clearly. 开启debug ,
                                                        // Set mailer to use SMTP
        $mail->Host = 'smtp.domain.com';  // Specify main and backup server
        $mail->SMTPAuth = true;                               // Enable SMTP authentication
        $mail->Username = 'mantis@domain.com';                            // SMTP username
        $mail->Password = 'passwod';                           // SMTP password
        //$mail->SMTPSecure = 'tls';                            // Enable encryption, 'ssl' also accepted 根据邮件服务器情况可选

        $mail->From = 'mantis@domain.com';
        $mail->FromName = 'Mailer';
        $mail->AddAddress('tosomeone@domain.com');  // Add a recipient
        $mail->WordWrap = 50;                                 // Set word wrap to 50 characters
  
        $mail->IsHTML(true);                                  // Set email format to HTML
        $mail->Subject = 'Here is the subject';
        $mail->Body    = 'This is the HTML message body <b>in bold!</b>';
        $mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
        if(!$mail->Send()) {
         echo 'Message could not be sent.';
         echo 'Mailer Error: ' . $mail->ErrorInfo;
         exit;
        }
        echo 'Message has been sent';
        $mail->SetLanguage('cn', '/optional/path/to/language/directory/');

?>

保存为send_email_test.php,然后在命令行运行  或在浏览器中打开 路径

#>  php send_email_test.php

可以看到和邮件服务器的交互,如下:CLIENT -> SMTP: EHLO 192.168.0.32
CLIENT -> SMTP: AUTH LOGIN
CLIENT -> SMTP: bWFudGlzQDgwMBBoYXJtLmNvbQ==
CLIENT -> SMTP: bWFudGlzcm9vRA==
CLIENT -> SMTP: MAIL FROM:
CLIENT -> SMTP: RCPT TO:
CLIENT -> SMTP: DATA
CLIENT -> SMTP: Date: Fri, 7 Nov 2014 17:10:27 +0800
CLIENT -> SMTP: Return-Path:
CLIENT -> SMTP: To: me@domain.com  #保护隐私,我做了修改
CLIENT -> SMTP: From: Mailer
CLIENT -> SMTP: Subject: Here is the subject
CLIENT -> SMTP: Message-ID: <1602e1113b26e1c0fac5c7878381e2f1@192.168.0.32>
CLIENT -> SMTP: X-Priority: 3
CLIENT -> SMTP: X-Mailer: PHPMailer 5.2.6 (https://github.com/PHPMailer/PHPMailer/)
CLIENT -> SMTP: MIME-Version: 1.0
CLIENT -> SMTP: Content-Type: multipart/alternative;
CLIENT -> SMTP: boundary="b1_1602e1113b26e1c0fac5c78978381e2f1"
CLIENT -> SMTP:
CLIENT -> SMTP: --b1_1602e1113b26e1c0fac5c78783081e2f1
CLIENT -> SMTP: Content-Type: text/plain; charset=iso-0859-1
CLIENT -> SMTP: Content-Transfer-Encoding: 8bit
CLIENT -> SMTP:
CLIENT -> SMTP: This is the body in plain text for non-HTML mail
CLIENT -> SMTP: clients
CLIENT -> SMTP:
CLIENT -> SMTP:
CLIENT -> SMTP: --b1_1602e1113b26e1c0fac5c7878381e2f1
CLIENT -> SMTP: Content-Type: text/html; charset=iso-8859-1
CLIENT -> SMTP: Content-Transfer-Encoding: 8bit
CLIENT -> SMTP:
CLIENT -> SMTP: This is the HTML message body in bold!
CLIENT -> SMTP:
CLIENT -> SMTP:
CLIENT -> SMTP:
CLIENT -> SMTP: --b1_1602e1113b26e1c0fac5c7078381e2f1--
CLIENT -> SMTP:
CLIENT -> SMTP: .
CLIENT -> SMTP: quit
Message has been sent

看到邮件发送成功,检查邮箱收到,

参考:

https://github.com/mantisbt/mantisbt  

http://sourceforge.net/projects/mantisbt/

https://github.com/PHPMailer/PHPMailer

http://www.mantisbt.org/docs/master-1.2.x/en/

http://www.pooy.net/mantis-send-email.html