Page 1 of 1

Changing Notification "from" address

Posted: Tue Aug 30, 2016 2:54 pm
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?

Re: Changing Notification "from" address

Posted: Tue Aug 30, 2016 3:06 pm
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?

Re: Changing Notification "from" address

Posted: Tue Aug 30, 2016 3:09 pm
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

Re: Changing Notification "from" address

Posted: Tue Aug 30, 2016 3:34 pm
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.

Re: Changing Notification "from" address

Posted: Tue Aug 30, 2016 3:48 pm
by derekb
You win the prize!! Thank you!!

Re: Changing Notification "from" address

Posted: Tue Aug 30, 2016 3:50 pm
by mcapra
Sure thing! Is it alright if we lock this thread and mark the issue as resolved?

Re: Changing Notification "from" address

Posted: Tue Aug 30, 2016 3:53 pm
by derekb
mcapra wrote:Sure thing! Is it alright if we lock this thread and mark the issue as resolved?
Yep! Thanks again !!