Inbound Email Configuration problem

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
stf_792
Posts: 48
Joined: Fri Jul 17, 2015 12:55 pm

Inbound Email Configuration problem

Post by stf_792 »

Hello,

NagiosXI 5.6 on CentOs 7.1 PHP 5.46

I am trying to configure inbound email under System Config-Email Settings. I put all values in (verified that nae and password work in browser), but when I click "Test Settings" I am getting

Code: Select all

Could not connect with the inbound settings given. Hide Details
Can't open mailbox {xxx.xxx.com:/imap}INBOX: invalid remote specification
Searching indicate possible problem with IMAP being enabled in PHP configuration.

I checked /etc/php.ini and did not find any mentioning of extensions. I do see imap.so and yum idicates that imap-php is installed.

Question:
How do I make inbound email work?

Thanks.
npolovenko
Support Tech
Posts: 3457
Joined: Mon May 15, 2017 5:00 pm

Re: Inbound Email Configuration problem

Post by npolovenko »

Hello, @stf_792. Can you run this command from the nagios server console and let me know if it fails or not?
/usr/local/nagios/libexec/check_email_delivery --mailto xxxxxxx --mailfrom xxxxxxx -H xx.xxx.xxx.xxx --smtp-server xx.xxx.xxx.xxx --smtp-username 'xxxxxxx' --smtp-password 'xxxxxxx ' --smtp-port 25 --imap-server xx.xxx.xxx.xxx --imap-username 'xxxxxxx' ---imap-password 'xxxxxxx ' --imap-port 143
Don't forget to replace all xxxx with the actual information.

Please upload: /var/log/maillog from the nagios server.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
jomann
Development Lead
Posts: 611
Joined: Mon Apr 22, 2013 10:06 am
Location: Nagios Enterprises

Re: Inbound Email Configuration problem

Post by jomann »

The above post will check your connection settings, however I do believe that it's connecting properly. What email provider are you using and does the user that you are connecting with have a folder/mailbox called INBOX available? We don't do any polling for mailboxes, we currently only have it set up to use the INBOX mailbox and if one does not exist it will error. You should be able to create it if it doesn't exist though.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
stf_792
Posts: 48
Joined: Fri Jul 17, 2015 12:55 pm

Re: Inbound Email Configuration problem

Post by stf_792 »

we are using our on-prem exchange server.

Sending is working fine, we can use 3rd party IMAP client to connect to mailbox.

please note that we trying to configure nagios xi 5.6 feature "acknowledge by email" by configuring inbound mail settings. php IMAP extension need to be enabled for that.

I do not think check_email_delivery applies in this case.

see screenshot
You do not have the required permissions to view the files attached to this post.
ssax
Dreams In Code
Posts: 7682
Joined: Wed Feb 11, 2015 12:54 pm

Re: Inbound Email Configuration problem

Post by ssax »

Please go to Admin > Manage Email Settings:
- Make sure Debug Log is checked
- Click the Update Settings button

Then edit this file:

Code: Select all

/usr/local/nagiosxi/html/includes/utils-email.inc.php
Change the two imap_open lines in there from this:

Code: Select all

$conn = imap_open($conn_string."INBOX", $user, $pass);
To this:

Code: Select all

$conn = imap_open($conn_string."INBOX", $user, $pass, 0, 1, array('DISABLE_AUTHENTICATOR' => 'GSSAPI'));
Then change this line (around line 350):

Code: Select all

$conn_string .= '/imap';
To this:

Code: Select all

$conn_string .= '/imap/debug';
Then run this tail command (and leave it running):

Code: Select all

tail -F /var/log/maillog /usr/local/nagiosxi/tmp/phpmailer.log /usr/local/nagiosxi/var/eventman.log /var/log/httpd/error_log /var/log/httpd/ssl_error_log
Then try it again and send us the full output from the screen and from the tail command above.

Thank you!
stf_792
Posts: 48
Joined: Fri Jul 17, 2015 12:55 pm

Re: Inbound Email Configuration problem

Post by stf_792 »

here it is

Code: Select all

/var/log/httpd/error_log <==
[Wed May 01 10:42:43.756071 2019] [:error] [pid 5530] [client xx.xx.xx.xx:52934] PHP Warning:  imap_open(): Couldn't open stream {mycasserver.mydomain.com:/imap/debug}INBOX in /usr/local/nagiosxi/html/includes/utils-email.inc.php on line 269, referer: http://myservername.mydomain.com/nagiosxi/admin/mailsettings.php
User avatar
tgriep
Madmin
Posts: 9190
Joined: Thu Oct 30, 2014 9:02 am

Re: Inbound Email Configuration problem

Post by tgriep »

Edit the /usr/local/nagiosxi/html/includes/utils-email.inc.php file again and change this back, to the original setting.

Code: Select all

$conn_string .= '/imap';
Save the file and edit this file

Around line 589 you should see this line

Code: Select all

$msg_lines_count = count($msg_lines);

Add these lines below that line

Code: Select all

echo "msg_end: " . $msg_end;
echo "\nmsg_lines_count: " . $msg_lines_count;
echo "\nmsg_lines: " . var_dump($msg_lines);
echo "\nmsg: " . $msg;
Save the file.

Reply to an Notification with a valid command.

Check the /usr/local/nagiosxi/var/cleaner.log file for any errors when the system checks the inbound email account.
Be sure to check out our Knowledgebase for helpful articles and solutions!
stf_792
Posts: 48
Joined: Fri Jul 17, 2015 12:55 pm

Re: Inbound Email Configuration problem

Post by stf_792 »

I updated to 5.61 - same error.

After taking 20th look, I relaized that IMAP port number need to be typed in, it looks like it prepopulated to 143, but it not.

After typing the port number and testing, error changed to

Code: Select all

SECURITY PROBLEM: insecure server advertised AUTH=PLAIN
Can not authenticate to IMAP server: AUTHENTICATE failed.
Since we only allow IMAP internally for selected mailboxes, I am not using any encryption for IMAP login. It is set to none.

I know that username and password are good - I can login to mailbox on other non-nagios applications.

I tried the following combinations for username:

domain\username
username
username@domain

Same error.

Is Nagios by default disables any plain text authentication?
stf_792
Posts: 48
Joined: Fri Jul 17, 2015 12:55 pm

SOLVED: Re: Inbound Email Configuration problem

Post by stf_792 »

As I mentioned earlier, IMAP port was the 1st problem. Port Hint looks like port already entered, while it was blank

The second problem was "!" character in mailbox password. "!" used as delimiter in Nagios, so after password change it stop giving Authentication errors.

However,

Code: Select all

SECURITY PROBLEM: insecure server advertised AUTH=PLAIN
message still remaining. Hopefully it will be suppressed on next build.
User avatar
tgriep
Madmin
Posts: 9190
Joined: Thu Oct 30, 2014 9:02 am

Re: Inbound Email Configuration problem

Post by tgriep »

Thanks for letting is know about the Port Hint causing issues. I put in a request to get that changed to be blank.

The message
SECURITY PROBLEM: insecure server advertised AUTH=PLAIN
May not be so easily to remove. What that I read, it is nor really an error, it is just a warning that you are using PLAIN text authentication.
You should only see that message when testing the InBox connection.

I just want to verify, after all of the changes, it is working for you now?
Be sure to check out our Knowledgebase for helpful articles and solutions!
Locked