I have installed nagios
for monitoring and sendmail
for sending mails. When testing from root
account I am receiving mails, but I'm not receiving mails when I send it from nagios
account. I have googled and found that only root
user can send mails using sendmail MTA
. How to enable sendmail
to send mails from nagios
account?
Note that I don't send messages directly from the local machine, but instead use my ISP/provider relay. The below logs show the error from the relay when the message comes from nagios@
, but not when it comes from root@
.
Output from nagios user:
cat /var/log/maillog
Sep 19 15:52:32 ubuntubackup-chennai sendmail[6088]: q8JAMWXZ006088: from=nagios, size=237, class=0, nrcpts=1, msgid=<[email protected]>, relay=nagios@localhost Sep 19 15:52:32 ubuntubackup-chennai sendmail[6089]: q8JAMWCn006089: from=<[email protected]>, size=517, class=0, nrcpts=1, msgid=<[email protected]>, proto=ESMTP, daemon=MTA, relay=localhost.localdomain [127.0.0.1] Sep 19 15:52:32 ubuntubackup-chennai sendmail[6088]: q8JAMWXZ006088: to=karthick.murugadhas@****.com, ctladdr=nagios (496/492), delay=00:00:00, xdelay=00:00:00, mailer=relay, pri=30237, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, stat=Sent (q8JAMWCn006089 Message accepted for delivery) Sep 19 15:52:32 ubuntubackup-chennai sendmail[6091]: q8JAMWCn006089: to=<karthick.murugadhas@****.com>, ctladdr=<[email protected]> (496/492), delay=00:00:00, xdelay=00:00:00, mailer=relay, pri=120517, relay=smtp10.netcore.co.in. [202.162.229.32], dsn=4.7.1, stat=Deferred: 450 4.7.1 <nagios@****.com>: Sender address rejected: Please checked sender domain
Output from root user:
cat /var/log/maillog
Sep 19 15:43:29 ubuntubackup-chennai sendmail[5158]: q8JADTt2005158: from=root, size=237, class=0, nrcpts=1, msgid=<[email protected]>, relay=root@localhost Sep 19 15:43:29 ubuntubackup-chennai sendmail[5159]: q8JADTFO005159: from=<[email protected]>, size=511, class=0, nrcpts=1, msgid=<[email protected]>, proto=ESMTP, daemon=MTA, relay=localhost.localdomain [127.0.0.1] Sep 19 15:43:29 ubuntubackup-chennai sendmail[5158]: q8JADTt2005158: to=karthick.murugadhas@****.com, ctladdr=root (0/0), delay=00:00:00, xdelay=00:00:00, mailer=relay, pri=30237, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, stat=Sent (q8JADTFO005159 Message accepted for delivery) Sep 19 15:43:30 ubuntubackup-chennai sendmail[5161]: q8JADTFO005159: to=<karthick.murugadhas@****.com>, ctladdr=<[email protected]> (0/0), delay=00:00:01, xdelay=00:00:01, mailer=relay, pri=120511, relay=smtp10.netcore.co.in. [202.162.229.32], dsn=2.0.0, stat=Sent (_SMR_smtp9.netcore.co.in Ok: queued as 29CE7F6D4C)
Update 1:
sendmail.mc
configuration file is here.
Edit: after extensive manual interrogation of your SMTP relay, it looks like the problem may be that the relay specifically blocks
nagios@
as a sender:Does the
nagios@****.com
mailbox exist? Can you try simply rewritingnagios
to e.g.nagios1
?To do this, in
/etc/sendmail.mc
add:Create file
/etc/mail/genericstable
and add the line:and
/etc/mail/generics-domains
and add lines:Then run
sudo sendmailconfig
and try again.The issue appears to be your SMTP relay at
netcore.co.in
. Hosting/ISP SMTP relays are never "open", and usually set to only relay mails from one of "their" domains and from one of "their" IPs. Mails fromroot@localhost
are probably getting through only because some mail server daemons recognize root and make an exception for it, sometimes even replacing the@localhost
part with whatever the reverse DNS (or IP) of the sender is (for example, my messages once went through in the form of[email protected]
). No such courtesy is afforded to the "nagios@localhost" user.Two solutions:
The easier one may be to simply set (or fake) your sendmail FQDN to whatever is recognized/authorized by Netcore.
To do this, open
/etc/mail/sendmail.mc
and add these lines at the end before anyMAILER
lines, modifying appropriately:Then run
sudo sendmailconfig
, answering yes to everything and make sure sendmail is restarted. See here for some more basic info on Sendmail masquerading for relaying.Alternatively, for the sake of completeness, to keep using nagios@localhost, you can do one of two things -- either disable relaying in sendmail and use it directly (if you have a static IP/PTR record or RDNS), OR you can set up sendmail to perform SMTP authentication with the Netcore relay.
These Netcore articles may help; you can try asking them too if possible:
First of all: Checking the web arround, and by looking at your logs, it doesn't seem to be an issue with the user nagios, rather, it seems to be an issue with sendmail's configuration.
To be more accurate, a user in this forum suggests he gets a similar
450 error code
(he was using postfix, but I assume that there is some kind of protocol) which, as in your situation too, denotes adomain not found
issue. To quote another user from that same forum:While you are using localhost as a sender domain, I still believe that there is more that can be taken care of.
As a matter of fact, another user from another forum I stumbled upon, seems to have a similar problem to the user in the first forum I linked to, and he too gets the same error code:
450
. In that same forum another user is quoted suggesting that it is a DNS issue too.Important: I am aware that you are using localhost and not a particular domain. However, to me it seems like it must be an misconfiguration issue of the
sendmail
program, rather than user nagios not having rights or anything.I have also found some other sources that I am researching currently. Will continue to update this answer as I get more and more information on the matter.
[EDIT #1]: Another user in another forum is quoted saying:
However the user asking the question there doesn't seem to face a
450 error code
. However he gets a similar answer to what I have seen so far on the interwebz.[EDIT #2]: The more I read about your problem, the more I get it: It seems like
nagios@localhost
that you have selected to use as the domain that sends the emails doesn't resolve to a valid Ip address, and that's what's causing thesmtp10.netcore.co.in
server to respond with a450 domain not found
response, for it believes that your mail is spam:The most probable fix is to make sure that you use a domain that is resolvable.
In my nagios configuration the command for sending mail ist
Try out if you can send mail as user nagios from the command line:
This may either fail because of a bad path, access rights or the mailserver not accepting the destination address. Please keep us posted on your test results.
Sendmail is kinda ancient. While some people think of it as the best mail server ever written, personally I do not enjoy it the least bit.
My combination for sending emails from local user accounts to "external" mail adresses is
postfix
andbsd-mailx
If you want to give it a try:
sudo apt-get install postfix bsd-mailx
.If you do not want to receive any emails on this host, you could make Postfix a little more secure by binding it to localhost. Run
sudo postconf -e 'inet_interfaces = localhost' && sudo service postfix restart
.