Display error by an unsuccessful attemp to send mail

Post about your customizations to share with others.

Moderators: Developer, Contributor

Post Reply
thomasbrooks
Posts: 5
Joined: 27 Dec 2010, 07:37

Display error by an unsuccessful attemp to send mail

Post by thomasbrooks »

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):

Code: Select all

PRINT 'Mailer Error: '. $mail->ErrorInfo.'<br />';
so that eventually the try..catch section looked like:

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 />';
	}
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
Thomas Brooks

Mantis: 1.2.4
PHP: 5.3.1
SQL: MySQL 5.1.41
OS: Windows Server 2003 R2, Standard Edition, SP2
Post Reply