Page 1 of 1

Email system - invalid

Posted: Tue Feb 14, 2017 7:47 am
by Neferkat
Dear Everyone!

First of all, thank you and the Nagios team for creating and maintaining such a great system. I hope in the future I will be able to contribute in some way, thus giving back a little to the community.

For now however, I have an issue which I can't quite figure out. I could probably "hack" my way to a solution but that's not how I want my first encounter with Nagios to be. And besides, I'm sure there're better ways of dealing with this.

Long story short... I'm trying to set up email notifications. I'm filling out all the required fields, all is correct as far as I can tell, but when I try to send a test mail, this is the error I get on Nagios-side:

Code: Select all


    A test email was sent to [email protected]
    ----
    Mailer said: [02-14-2017 13:34:18] SMTP Error: Could not authenticate. (method=smtp;host=border.dodonet.hu;port=465;smtpauth=true;security=ssl), Referer: admin/testemail.php
    An error occurred sending a test email!

At the same time, on server side I see this:

Code: Select all

Feb 14 13:34:18 border postfix/smtpd[6740]: connect from catv-xxx-xxx-xxx-54.catv.broadband.hu[xxx.xxx.248.54]
Feb 14 13:34:18 border postfix/smtpd[6740]: warning: catv-xxx-xxx-xxx-54.catv.broadband.hu[xxx.xxx.248.54]: SASL LOGIN authentication failed:[b] Invalid authentication mechanism[/b]
So invalid authentication mechanism.

I tried with a number of other settings, but it seems like Nagios wants to auth against the server using "LOGIN" mechanism - which is not going to work, since it's not enabled.

My question: Is there a "clean" way to make the mailer inside Nagios (Phpmailer I think) use the "PLAIN" mechanism instead?

Thank you for your kind advices!

Best Regards,

Levente

Re: Email system - invalid

Posted: Tue Feb 14, 2017 11:51 am
by rkennedy
Can you post a full screenshot of your manage email settings?

If you're looking to edit the raw files, the two ones you're probably after are usr/local/nagiosxi/html/includes/utils-email.inc.php and usr/local/nagiosxi/html/includes/phpmailer/*

Re: Email system - invalid

Posted: Tue Feb 14, 2017 12:03 pm
by Neferkat
Hey, thank you for your answer!
rkennedy wrote:Can you post a full screenshot of your manage email settings?
Sure thing, I've attached it...
rkennedy wrote:If you're looking to edit the raw files, the two ones you're probably after are usr/local/nagiosxi/html/includes/utils-email.inc.php and usr/local/nagiosxi/html/includes/phpmailer/*
Thanks for pointing me to the right direction - that's what I'll do if nothing else helps, I think...

Re: Email system - invalid

Posted: Tue Feb 14, 2017 3:41 pm
by rkennedy
Does the user you blanked out have correct send as permissions for nagios.nyh@fqdn? Just want to make sure we're not missing this part.

There isn't a 'clean' way to disable the amtpauth. Open up the utils-email.inc.php and change this part to false -

Code: Select all

            $mail->SMTPAuth = true;
Then attempt again - are things working, or are you seeing a different error by chance?

Re: Email system - invalid

Posted: Tue Feb 14, 2017 4:54 pm
by Neferkat
rkennedy wrote:Then attempt again - are things working, or are you seeing a different error by chance?
As expected, it didn't work. That system wasn't designed to allow unauth. mail from non-local nets...

So I did the following dirty hack - maybe it will help someone...

1) I went and took a really good look inside the phpmailer implementation that's being used... Turns out, I wouldn't be able to "adjust" the login mechanism from "LOGIN" to "PLAIN", because it simply isn't there. That library only supports "LOGIN", after setting up SSL, whereas I need "PLAIN".

2) Realizing that, I decided I won't reinvent the wheel, instead I went and pulled the entrie phpmailer library from github https://github.com/PHPMailer/PHPMailer and copied it inside includes/phpmailer, overwriting all. Then set the permissions similar to the original.

3) I modified the firs lines (after the comments) of the core class.phpmailer.php file so that it pulls in the necessary SMTP and POP3 modules for Nagios, like so:

Code: Select all

require_once("smtp.class.php");
require_once("pop3.class.php");
4) Finally to be on the safe side I also modified /usr/local/nagiosxi/html/includes/utils-email.inc.php to set the appropriate AuthType property for the mail object, like so:

Code: Select all

       if (have_value($smtpusername) == true) {
            $debuginfo .= ";smtpauth=true";
            $mail->SMTPAuth = true;
            $mail->Username = $smtpusername;
            $mail->Password = $smtppassword;
            $mail->AuthType = 'PLAIN';
        }
There...

AND!!! It now works like a charm :D :D :D :D

Thank you sincerely for putting my finger onto the place where the issue was hiding!

Take good care!!

Levente

Re: Email system - invalid

Posted: Tue Feb 14, 2017 5:09 pm
by rkennedy
Got it - wasn't familiar with needing to force AuthType - thought it was the SMTPAuth. Regardless though, glad you were able to get it working!

Thanks for sharing your solution, too!

Re: Email system - invalid

Posted: Wed Mar 01, 2017 2:28 pm
by tmcdonald
Closing. PM if you need it re-opened.