Wednesday, May 8, 2024
 Popular · Latest · Hot · Upcoming
6
rated 0 times [  6] [ 0]  / answers: 1 / hits: 11222  / 2 Years ago, sun, october 16, 2022, 9:33:40

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




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


More From » nagios3

 Answers
0

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




[#35747] Tuesday, October 18, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
ersoggles

Total Points: 69
Total Questions: 111
Total Answers: 111

Location: Vanuatu
Member since Sun, Oct 2, 2022
2 Years ago
;