Changing Notification "from" address

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
derekb
Posts: 177
Joined: Wed Jun 10, 2015 1:54 pm

Changing Notification "from" address

Post by derekb »

Howdy,
Just glancing over this article I found online:
http://serverfault.com/questions/73004/ ... mails-from

Has anyone had any success doing this? I have a requirement to change the "From" address for notifications for certain sites to get them into a CRM properly.

I've tried a few things so far by trying to run the commands manually from CLI:

Code: Select all

/bin/mail -s "** $NOTIFICATIONTYPE$ Service Alert: $HOSTNAME$ is $HOSTSTATE$ **" [email protected] -- -r "[email protected]"
/bin/mail -s "** $NOTIFICATIONTYPE$ Service Alert: $HOSTNAME$ is $HOSTSTATE$ **" [email protected] -- -r [email protected]
/bin/mail -s "** $NOTIFICATIONTYPE$ Service Alert: $HOSTNAME$ is $HOSTSTATE$ **" [email protected] -- [email protected]
Pretty much everything in the link above I have tried, and the 'mail' command just seems to hang. I don't see anything in /var/log/maillog.

Any ideas?
User avatar
mcapra
Posts: 3739
Joined: Thu May 05, 2016 3:54 pm

Re: Changing Notification "from" address

Post by mcapra »

Does changing the "Send Mail From" field under your mail settings not produce the desired result?
2016_08_30_15_05_14_Nagios_XI_Administration.png
If so, could you explain in greater depth what the desired result is?
You do not have the required permissions to view the files attached to this post.
Former Nagios employee
https://www.mcapra.com/
derekb
Posts: 177
Joined: Wed Jun 10, 2015 1:54 pm

Re: Changing Notification "from" address

Post by derekb »

mcapra wrote:Does changing the "Send Mail From" field under your mail settings not produce the desired result?
2016_08_30_15_05_14_Nagios_XI_Administration.png
If so, could you explain in greater depth what the desired result is?
I don't want to use a "system wide" FROM address. I'm trying to create a new command for sending notifications via email to change the default FROM address to something specific for certain hosts/services
User avatar
mcapra
Posts: 3739
Joined: Thu May 05, 2016 3:54 pm

Re: Changing Notification "from" address

Post by mcapra »

Ah, I understand.

It's worth mentioning using the various Nagios XI macros in the CLI isn't going to work. The macros don't have meaning outside of Nagios XI.

If I run the following from the CLI:

Code: Select all

[root@localhost etc]# /usr/bin/printf "%b" "this is a test email" | /bin/mail -s "** TEST ALERT **" [email protected]
I get the following in my inbox (ignore the spam tagging):
2016_08_30_15_25_30_TEST_ALERT_myemail_gmail.com_Gmail.png
So lets say [email protected] isn't ideal and I want to change the "from" address as you are trying to do. From the CLI I give this a shot:

Code: Select all

[root@localhost etc]# /usr/bin/printf "%b" "this is a test email" | /bin/mail -r [email protected] -s "** TEST ALERT **" [email protected]
I get the following in my inbox:
2016_08_30_15_30_59_TEST_ALERT_myemail_gmail.com_Gmail.png
So I think a well placed -r argument should do the trick.
You do not have the required permissions to view the files attached to this post.
Former Nagios employee
https://www.mcapra.com/
derekb
Posts: 177
Joined: Wed Jun 10, 2015 1:54 pm

Re: Changing Notification "from" address

Post by derekb »

You win the prize!! Thank you!!
User avatar
mcapra
Posts: 3739
Joined: Thu May 05, 2016 3:54 pm

Re: Changing Notification "from" address

Post by mcapra »

Sure thing! Is it alright if we lock this thread and mark the issue as resolved?
Former Nagios employee
https://www.mcapra.com/
derekb
Posts: 177
Joined: Wed Jun 10, 2015 1:54 pm

Re: Changing Notification "from" address

Post by derekb »

mcapra wrote:Sure thing! Is it alright if we lock this thread and mark the issue as resolved?
Yep! Thanks again !!
Locked