Display error by an unsuccessful attemp to send mail
Posted: 30 Dec 2010, 21:56
Recently I've had problems in configuring Mantis to be able to collaborate with my company's Exchange server in order to send emails.
My problem was, that emails were sent successfully through gmail, using the configuration explained in http://www.mantisbt.org/forums/viewtopi ... =3&t=15398, but through the exchange - nothing happened. Of course, I've properly changed the host name, username, password etc.
Unfortunately, no any error appeared. On screen everything appears as successful, but emails haven't send/receive.
Exploring the email_api.php file (in mantis/core folder), I've decided to add the following line in the "catch" section which is invoked when there is a problem in the sending process (after line # 1006):
so that eventually the try..catch section looked like:
and then, using the built in test_email page (see about it in the aforementioned link), I've tried to send mail.
This time, I've got a much more meaningful error - not just the generic "There was a problem" one.
It appeared to be because of undefining the $g_return_path_email value to appropriate value. The default value of "admin@example.com" in config_defaults_inc.php didn't have permissions in the exchange. Defining it to be the same user of which username is used, solved the problem.
And another tip which was revealed to me: Exchange requires the $g_smtp_connection_mode to be defined on 'tls', although usually the regular port 25 is used. See about this in http://stackoverflow.com/questions/1233 ... mail-works
My problem was, that emails were sent successfully through gmail, using the configuration explained in http://www.mantisbt.org/forums/viewtopi ... =3&t=15398, but through the exchange - nothing happened. Of course, I've properly changed the host name, username, password etc.
Unfortunately, no any error appeared. On screen everything appears as successful, but emails haven't send/receive.
Exploring the email_api.php file (in mantis/core folder), I've decided to add the following line in the "catch" section which is invoked when there is a problem in the sending process (after line # 1006):
Code: Select all
PRINT 'Mailer Error: '. $mail->ErrorInfo.'<br />';Code: Select all
try
{
if ( !$mail->Send() ) {
$t_success = false;
} else {
$t_success = true;
if ( $t_email_data->email_id > 0 ) {
email_queue_delete( $t_email_data->email_id );
}
}
}
catch ( phpmailerException $e )
{
$t_success = false;
PRINT 'Mailer Error: '. $mail->ErrorInfo.'<br />';
}This time, I've got a much more meaningful error - not just the generic "There was a problem" one.
It appeared to be because of undefining the $g_return_path_email value to appropriate value. The default value of "admin@example.com" in config_defaults_inc.php didn't have permissions in the exchange. Defining it to be the same user of which username is used, solved the problem.
And another tip which was revealed to me: Exchange requires the $g_smtp_connection_mode to be defined on 'tls', although usually the regular port 25 is used. See about this in http://stackoverflow.com/questions/1233 ... mail-works