Configuring MantisBT to send emails using GMail

青春壹個敷衍的年華 提交于 2019-11-28 09:50:26

According to a posting on the MantisBT forums, these are working settings for GMail:

$g_phpMailer_method = PHPMAILER_METHOD_SMTP;
$g_smtp_host = 'smtp.gmail.com';
$g_smtp_username = 'username@gmail.com';
$g_smtp_password = 'yourpassword';
$g_smtp_connection_mode = 'ssl';
$g_smtp_port = 465;
$g_phpMailer_method = PHPMAILER_METHOD_SMTP;
$g_smtp_host = 'smtp.gmail.com';
$g_smtp_username        = 'username';   // without @gmail.com
$g_smtp_password        = 'password';
$g_smtp_connection_mode = 'ssl';
$g_smtp_port = 465;

it Works for me

Something to add about GMail. These settings are correct but GMail has instituted some new security that will still prevent email from being sent from Mantis or any other mailer using the SMTP connector.

In order to do this with GMail, you must "Allow less secure apps to access accounts". In GMail admin, there is a setting to allow users to control access from "less secure apps," which must be turned on, and then the user account used to send mail must turn on access from "less secure apps." The link above provides the information on how to configure this.

The frustrating thing is everything will appear to work fine but no emails are sent. There is no error indication from the SMTP server. However, the user account used to send mail may receive an email from GMail indicating someone is trying to access the account. I spent hours trying to track this down.

If anyone still faces issue or error while configuration add log level so that you can drill down the problem further. Below settings worked for me. Detailed explanation is written here

$g_phpMailer_method = PHPMAILER_METHOD_SMTP;
$g_smtp_host = ‘smtp.gmail.com’;
$g_smtp_port = ‘465’;
$g_smtp_connection_mode = ‘ssl’;
$g_smtp_username = ‘letzdotesting@gmail.com’;
$g_smtp_password = ‘xxxxx’;
$g_administrator_email = ‘letzdotesting@gmail.com’;
$g_webmaster_email = ‘letzdotesting@gmail.com’;
$g_from_email = ‘letzdotesting@gmail.com’;
$g_return_path_email = ‘letzdotesting@gmail.com’;
$g_default_timezone = ‘UTC’;
$g_log_level = LOG_EMAIL | LOG_EMAIL_RECIPIENT;
$g_log_destination = ‘file:C:\mantisbt.log’;

2017 update (MantisBT 2.3.0) Please follow the steps below:

[1] IF YOU'RE USING DOCKER

Access the docker instance running the command below:

docker exec -it {docker-id} bash

[2] INSIDE MANTISBT SERVER

if you dont have any editor:

# sudo apt-get update
# apt-get install vim

create a log file:

# touch /var/log/mantisbt.log
# cd /var/log/
# chmod 777 mantisbt.log

[3] EDITING MANTISBT CONFIGURATION

# vim /var/www/html/config/config_inc.php

add the following content to the file opened in the earlier step:

$g_phpMailer_method = PHPMAILER_METHOD_SMTP;
$g_administrator_email = 'your-admin-email@gmail.com';
$g_webmaster_email = 'your-webmaster-email@gmail.com';
$g_return_path_email = 'your-return-email@gmail.com';
$g_from_email = 'your-from-email@gmail.com';

$g_smtp_host = 'smtp.gmail.com';
$g_smtp_port = 465;
$g_smtp_connection_mode = 'ssl';
$g_smtp_username = 'username';
$g_smtp_password = 'password';

$g_log_level = LOG_EMAIL | LOG_EMAIL_RECIPIENT;
$g_log_destination = 'file:/var/log/mantisbt.log';

$g_validate_email = OFF;

[4] EDITING GMAIL CONFIGURATION

You need to do this in order to allow MantisBT authentication:

  1. Access the following URL:

    https://myaccount.google.com

  2. Navigate to the Sign-in & Security menu-item under menu-tree.

  3. Check the "Allow less secure apps" option and set equals to true

Image:

You're good to go! Tested and running with these configurations. =]

My issue was solved by updating ca certificates. I am using Xampp, with PHP 7.2 on Windows sever 2012.

Although the below link provides you with the details, I mention the relavent part too:

Updating CA certificates

Updating CA certificates To update your CA certificates, make sure your operating system is fully up to date - CA certs are usually updated via OS updates. Alternatively, you can download the latest CA cert file from curl, install it somewhere accessible (for example /etc/ssl/cacert.pem) and point at it from the openssl.cafile and curl.cainfo directives in your php.ini file (this location will vary according to your OS and PHP config; where you need to put it is beyond the scope of PHPMailer!):

openssl.cafile = /etc/ssl/cacert.pem 
curl.cainfo = /etc/ssl/cacert.pem

https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting#updating-ca-certificates

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!