Unable to send email messages


#1

hello all
firstly, i apologise for the long post!!!
the problem i have is that i can not send email alerts using Nagios Version 3.0rc2 on OpenSuse10.3

uk-lds-nag-01:/ # cat /proc/version
Linux version 2.6.22.17-0.1-default (geeko @ buildhost) (gcc version 4.2.1 (SUSE Linux)) #1 SMP 2008/02/10 20:01:04 UTC

I have created an account in /home/nagios/.mailrc which uses our internal mail server:-

account mpl {
set record=+Sent
set from="nagios .admin @ mydomain.com (Nagios Admin)"
set smtp=192.168.100.2
}

if i go to the command line as the local user “nagios” and use:-

whoami | mailx -A mpl -s "The Subject" the.recipient @ mydomain.cmo

then i get an email in the.reci pient @ mydomain.com no problem.

however, the problem comes when trying to use the mailx command from within nagios; to test the command was being called, i used the definition:-

define command{
	command_name	notify-rp-by-email
	command_line	whoami >> /test.log
	}

when “notify-rp-by-email” is called, sure enough, it writes a file called /test.log and subsequently adds to it. Interestingly enough, the user name returned by this command is “nagios”.

I changed the definition command_line to

	command_line	echo "Test email body" | mailx -A mpl -s "Test email subject" the. recipient @ mydomain.com

restarted the nagios service and waited; no email was created or sent :frowning:
although nagios.log did recognise the service problem and tried to call the command_line as expected

[1205773389] SERVICE NOTIFICATION: mplanet1;rp-laptop;WIN - Drive Space C:;CRITICAL;notify-rp-by-email;c:\ - total: 149.05 Gb - used: 76.17 Gb (51%) - free 72.88 Gb (49%)

I did notice that in my /var/spool/mail/nagiosp file, I had the following entries from previous tests:-

From MAILER-DAEMON  Sat Mar 15 10:14:48 2008
Return-Path: <>
X-Original-To: nagios @ uk-lds-nag-01.mydomain.local
Delivered-To: nagios @ uk-lds-nag-01.mydomain.local
Received: by uk-lds-nag-01.mydomain.local (Postfix)
	id 892E72C7DE; Sat, 15 Mar 2008 10:14:48 +0000 (GMT)
Date: Sat, 15 Mar 2008 10:14:48 +0000 (GMT)
From: MAILER-DAEMON @ uk-lds-nag-01.mydo main.local (Mail Delivery System)
Subject: Undelivered Mail Returned to Sender
To: nagios @ uk-lds-nag-01.mydom ain.local
Auto-Submitted: auto-replied
MIME-Version: 1.0
Content-Type: multipart/report; report-type=delivery-status;
	boundary="90D042C7D9.1205576088/uk-lds-nag-01.mydo main.local"
Message-Id: <20080315101448.892E72C7DE @ uk-lds-nag-01.mydo main.local>

This is a MIME-encapsulated message.

--90D042C7D9.1205576088/uk-lds-nag-01.mydomain.local
Content-Description: Notification
Content-Type: text/plain; charset=us-ascii

This is the mail system at host uk-lds-nag-01.minorplanet.local.

I'm sorry to have to inform you that your message could not
be delivered to one or more recipients. It's attached below.

For further assistance, please send mail to postmaster.

If you do so, please include this problem report. You can
delete your own text from the attached returned message.

                   The mail system

<the.recipient @ mydo maincom>: delivery temporarily suspended: connect to
    exchange.myd omain.com[xxx.xxx.xxx.xxx]: Connection timed out

when I telnet’d to the xxx.xxx.xxx.xxx ip address above on port 25, i find this is our EXTERNAL spam filter machine! I spoke to my IT people who said that internal email does not go through this filter and couldn’t explain why it is!

Both the “from” address and the “to” address are internal addresses although I can not figure out where it is getting the “from” address from taken from the delivery failure

:frowning:

I appreciate that linux flavours do vary quite a lot but mailx is pretty standard (I think!!) i have read the man pages for mailx and it says to get it to work you need to

  1. create a .mailrc file in the users’ home directory (done)
  2. use the “-A {account}” switch when calling it (done - the {account} is specified in the .mailrc file created in step #1)

like i said, if i call mailx from the command line itself, it works and an email is sent and received but calling from from “command_line” in a cfg file in nagios, does neither :frowning:

Any ideas, suggestions or bullets for my gun, so i can shoot myself in the face so i don’t have this headache lol :wink:


#2

WOOO HOOO, I have solved it!!!
By adding

-r "sender.email @ domain.com"

into the command_line, I now get my emails :smiley: