Page 1 of 2

Gmail Account for Email Alerts

Posted: Mon Oct 03, 2016 7:21 pm
by Hugo
Hi everyone,

I cannot seem to get a gmail account working to send email logs with. I have tried a normal pop account and it works fine.

Sendmail says it works but nothing comes through
SMTP says the below

A test email was sent to [email protected]
----
Mailer said: SMTP Error: Could not connect to SMTP host. (method=smtp;host=smtp.gmail.com;port=465;smtpauth=true;security=ssl)
An error occurred sending a test email!


I have tried SSL, TLS and none. I have also enabled "Less Secure Apps" within the gmail account.

Is there something i'm missing?

Re: Gmail Account for Email Alerts

Posted: Tue Oct 04, 2016 11:04 am
by dwhitfield
Can you post a screenshot of your SMTP settings, censoring out any sensitive information?

Also, can you send another test email then immediately run tail -n20 /var/log/httpd/error_log from the command line and post the results?

Re: Gmail Account for Email Alerts

Posted: Tue Oct 04, 2016 4:01 pm
by tgriep
Also, can you run these commands and post the output so we can see the errors when an email is being sent from your server?

Code: Select all

tail -50 /var/log/maillog
tail -50 /usr/local/nagiosxi/tmp/phpmailer.log

Re: Gmail Account for Email Alerts

Posted: Tue Oct 04, 2016 11:01 pm
by Hugo
Below is my settings
Image

Ok so I have just tested sending the alerts to another GMail account and it works fine.(except is going to junk)

Were using Symantec.cloud's spam protection for our exchange server and I'm going to use it to try find a trace of the message. (have added the address as an whitelisted sender in Symantec.cloud as well as exchange)

the destination address has not changed. we were using the ISP's POP account to send alerts but changed ISP's and have issues getting a gmail account to work.

Re: Gmail Account for Email Alerts

Posted: Tue Oct 04, 2016 11:15 pm
by Hugo
Ok so weird things

according to /var/log/maillog it seems to be trying to connect to our domain.com:25 and matching to our public IP. however that's the website host. its not looking up the MX records for domain.com


Image

phpmailer.log
Image

Re: Gmail Account for Email Alerts

Posted: Wed Oct 05, 2016 10:26 am
by tgriep
Your mail method settings for XI are using the Sendmail so we only need to concern ourselves the the errors in the /var/log/maillog file.
The php log is for if you are using the SMTP Mail Method.

It looks like the XI server cannot connect to the mail host, so can you verify that the XI server can Ping the mail host and that it is allowed to relay email through it?

Re: Gmail Account for Email Alerts

Posted: Wed Oct 05, 2016 5:31 pm
by Hugo
Hi,

yes it can ping smtp.gmail.com no problem.
its weird i can send to another gmail account just not our exchange server (obviously all other exchange mail flows fine)

Re: Gmail Account for Email Alerts

Posted: Thu Oct 06, 2016 10:24 am
by tgriep
If the Nagios server cannot use your exchange server to relay emails as it is being blocked, you will have to have someone allow the Nagios server to relay through it.

Re: Gmail Account for Email Alerts

Posted: Thu Oct 06, 2016 11:54 am
by avandemore
Hi Hugo,

It's not entirely clear to me what email process you are trying to invoke.

In Nagios XI > Admin > Manage Email Settings, Sendmail should be chosen if you want an MTA on your local box to deliver the message(or is configured to relay it). SMTP should be chosen if you want an external SMTP server to relay the message in your case gmail?. In the latter scenario, the message will arrive to the contact's email address as from the smtp account used to login to gmail.

If you want the email to simply be delivered to a gmail address, chose Sendmail and change the contact's email to the gmail address.

Re: Gmail Account for Email Alerts

Posted: Sun Oct 09, 2016 5:31 pm
by Hugo
Thanks avandemore, that clears things up.

in that case I do want to use SMTP.
however SMTP gives me the following error

"A test email was sent to [email protected]
----
Mailer said: [10-10-2016 08:30:17] SMTP Error: Could not connect to SMTP host. (method=smtp;host=smtp.gmail.com;port=465;smtpauth=true;security=ssl), Referer: admin/testemail.php
An error occurred sending a test email!"

like mentioned earlier the nagiosxi server can ping smtp.gmail.com no problem.