Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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:

  1. cat /var/log/maillog

    Sep 19 15:52:32 ubuntubackup-chennai sendmail[6088]: q8JAMWXZ006088: from=nagios, size=237, class=0, nrcpts=1, msgid=<201209191022.q8JAMWXZ006088@localhost.localdomain>, relay=nagios@localhost
    Sep 19 15:52:32 ubuntubackup-chennai sendmail[6089]: q8JAMWCn006089: from=<nagios@localhost.localdomain>, size=517, class=0, nrcpts=1, msgid=<201209191022.q8JAMWXZ006088@localhost.localdomain>, 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=<nagios@localhost.localdomain> (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:

  1. cat /var/log/maillog

    Sep 19 15:43:29 ubuntubackup-chennai sendmail[5158]: q8JADTt2005158: from=root, size=237, class=0, nrcpts=1, msgid=<201209191013.q8JADTt2005158@localhost.localdomain>, relay=root@localhost
    Sep 19 15:43:29 ubuntubackup-chennai sendmail[5159]: q8JADTFO005159: from=<root@localhost.localdomain>, size=511, class=0, nrcpts=1, msgid=<201209191013.q8JADTt2005158@localhost.localdomain>, 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=<root@localhost.localdomain> (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.

share|improve this question
3  
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 –  izx Sep 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... –  Avio Sep 14 '12 at 8:12
add comment

4 Answers 4

up vote 6 down vote accepted
+500

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:

[izx.I5] ? telnet smtp10.netcore.co.in 25
220 ESMTP
EHLO ********.com
...
MAIL FROM:nagios@********.com
250 2.1.0 Ok
RCPT TO:karthick@********.com
450 4.7.1 : Sender address rejected: Please checked sender domain
quit
221 2.0.0 Bye
Connection closed by foreign host

Does the nagios@****.com mailbox exist? Can you try simply rewriting nagios to e.g. nagios1?

To do this, in /etc/sendmail.mc add:

FEATURE(`genericstable')dnl
GENERICS_DOMAIN_FILE(`/etc/mail/generics-domains')dnl

Create file /etc/mail/genericstable and add the line:

nagios nagiosk

and /etc/mail/generics-domains and add lines:

localhost
localhost.localdomain

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 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:

share|improve this answer
    
Great answer, a +1 from me =) –  NlightNFotis Sep 19 '12 at 12:26
    
@karthick87 can you paste the logs with masquerading enabled? –  izx Sep 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. –  izx Sep 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. –  izx Sep 20 '12 at 8:06
    
let us continue this discussion in chat –  izx Sep 20 '12 at 10:04
add comment

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.

[EDIT #1]: Another user in another forum is quoted saying:

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.

share|improve this answer
    
I dont think so, because i am receiving mail sucessfully when it is send from root user. –  karthick87 Sep 19 '12 at 11:37
    
@karthick87 See my last edit. –  NlightNFotis Sep 19 '12 at 11:37
    
@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 –  NlightNFotis Sep 19 '12 at 11:43
    
So what could be the solution?? –  karthick87 Sep 19 '12 at 12:08
    
@karthick87 I would suggest setting up sendmail to send mails from a different domain than localhost, as it gets filtered out. –  NlightNFotis Sep 19 '12 at 12:22
show 8 more comments

In my nagios configuration the command for sending mail ist

/usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\n\nService: $SERVICEDESC$\nHost: $HOSTALIAS$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: $LONGDATETIME$\n\nAdditional Info:\n\n$SERVICEOUTPUT$\n" | /usr/bin/mail -s "** $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" $CONTACTEMAIL$

Try out if you can send mail as user nagios from the command line:

su nagios
echo "test sendmail" | /usr/bin/mail -s "test" yourmail@domain.tld

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.

share|improve this answer
    
Thankyou Floyd. Pls see the updated questions with required logs.. –  karthick87 Sep 19 '12 at 10:33
add comment

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.

share|improve this answer
    
Sorry i dont prefer postfix. –  karthick87 Sep 14 '12 at 4:25
    
@pgschk: Did you even read the question? –  Avio Sep 14 '12 at 7:58
2  
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. –  pgschk Sep 14 '12 at 11:39
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.