Page 1 of 1

Email Configuration

Posted: 24 Nov 2017, 14:56
by Tarlix
Hello,

I'm using Mantis for a while and suddenly (probably somebody updated something, but no one said anything) in my company it just stopped sending emails.
I'm about 2 weeks now searching what could have happened on our server, so I configured the enviroment on my own machine and the problem persists.

Yesterday could make it work, but I had to change mantis email_api.php, and so, that's why I'm asking if there's any other way to fix the problem without change this code (thinking about future compatibility changes, or system backup).

So, this is what i've done:

config_inc.php:
$g_phpMailer_method = PHPMAILER_METHOD_SMTP;
$g_smtp_host = 'smtp.gmail.com';
$g_smtp_username = 'myemail@gmail.com';
$g_smtp_password = 'mypass';
$g_smtp_connection_mode = 'tls';
$g_smtp_port = 587;
$g_from_name = 'Mantis Bug Tracker';
$g_administrator_email = 'myemail@gmail.com';
$g_webmaster_email = 'myemail@gmail.com';
$g_return_path_email = 'myemail@gmail.com';
$g_from_email = 'myemail@gmail.com';
$g_validate_email = ON;
$g_log_level = LOG_EMAIL | LOG_EMAIL_RECIPIENT | LOG_FILTERING | LOG_AJAX;
$g_log_destination = 'file:C:\mantisbt.log';

--------
email_api.php

Added in function email_send( EmailData $p_email_data ):

Code: Select all

	$t_mail->SMTPOptions = array(
    'ssl' => array(
        'verify_peer' => false,
        'verify_peer_name' => false,
        'allow_self_signed' => true
    )
);
My system versions:
Windows server 2012;
MantisBT Version 1.3.1
PHP Version 5.6.18
Schema Version 209
ADOdb Version 5.20.4

Without this piece of code I got the following error:
Warning: stream_socket_enable_crypto(): SSL operation failed with code 1.
OpenSSL Error messages: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed

I saw on github this pull-request which would create a configuration that could solve my problem, I think.
https://github.com/mantisbt/mantisbt/pull/1135

Re: Email Configuration

Posted: 15 Jan 2018, 14:07
by androponia
Hello, where do i add that piece of code? in the function email_send( EmailData $p_email_data ) , but where? could you specify the line numer? Thanks!!!!

Re: Email Configuration

Posted: 16 Jan 2018, 12:10
by androponia
i figured out,

case PHPMAILER_METHOD_SMTP:
$t_mail->IsSMTP();

$t_mail->SMTPOptions = array(
'ssl' => array(
'verify_peer' => false,
'verify_peer_name' => false,
'allow_self_signed' => true
)
);

# SMTP collection is always kept alive
$t_mail->SMTPKeepAlive = true;

if( !is_blank( config_get( 'smtp_username' ) ) ) {
# Use SMTP Authentication
$t_mail->SMTPAuth = true;
$t_mail->Username = config_get( 'smtp_username' );
$t_mail->Password = config_get( 'smtp_password' );
}

Thanks!