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@.

Update 1:

Sendmail should allow non-root users to send as long as the domain is local/you have an FQDN. Can you please pastebin from /var/log: mail.log, mail.err, mail.info, mail.warn
–
izxSep 14 '12 at 5:24

2

It's really hard to try to help without more details on the problem and some logfile. You could try to follow this thread to see what's happening when nagios tries to use sendmail, and post back some more info...
–
AvioSep 14 '12 at 8:12

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 from root@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 root@dsl-111-222-111-222.ppp.isp.com). 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 any MAILER lines, modifying appropriately:

MASQUERADE_AS('karthick.com')
FEATURE(`masquerade_envelope')

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:

@karthick87 can you paste the logs with masquerading enabled?
–
izxSep 20 '12 at 6:31

The same ones I asked in my original comment to the question: mail.log, mail.err, mail.info, mail.warn . Also include your sendmail.mc and sendmail.cf.
–
izxSep 20 '12 at 6:38

@karthick87: this appears to be a problem with the netcore smtp configuration; it seems to disallow nagios@ addresses. See edit at top to try rewriting it to something different and see if it works.
–
izxSep 20 '12 at 8:06

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 a domain not found issue. To quote another user from that same forum:

This is usually due to a misconfiguration of your e-mail client if the
sender address is for a non-existent domain. It could also be, if
yours is a new domain, that the receipent's mail server has not caught
up with DNS propagation yet.

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.

It appears you are sending from root@machine.mydomaine, when the
receiving server does a reverse lookup on this address it will fail as
it is not valid and hence the mail will be rejected correctly with the
error you have given. Ensure you have a valid server name/domain for
your server and that it can be looked up in dns both forward and
reverse.

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 the smtp10.netcore.co.in server to respond with a 450 domain not found response, for it believes that your mail is spam:

Yep,"reject_unknown_sender_domain" can cause a lot of false positives,
but it does cut down on the spam.

The most probable fix is to make sure that you use a domain that is resolvable.

@karthick87 And it's not a matter of what you think it is, it's a matter of what your log files are reporting. The root@localhost may be resolving to something different than nagios@localhost, if it (nagios) resolves at all. Here is another source I found that could help you clarify what the 450 error code means, and it also backs my theory: systembash.com/content/450-vs-550-smtp-errors
–
NlightNFotisSep 19 '12 at 11:43

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 and bsd-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.

Of course I did. I just felt like the focus was on having Nagios send emails, not on using sendmail. So I offered the OPTION to try something that I know for a fact works. That's why I wrote "If you want to give it a try", see? However if sendmail is so important: I replaced my postfix with sendmail on the Nagios machine, and it works out of the box, so it looks like OP modified something and that broke it.
–
pgschkSep 14 '12 at 11:39