Generats a e-mail when something happend

Functionality and usage of the OpenNethome Server
Quicken
Posts: 6
Joined: Tue Oct 27, 2015 5:32 pm

Generats a e-mail when something happend

Post by Quicken »

I would like to send a mail when something happend in NetHome.
Example when temp goes low or high or maybe some movement or when a door bell button pushed.
I have config my RPI box so its possible to run command for send mail.
mail -s "Warning from NetHome" xxxxx@xxxxx.xx < message.txt

But how to run this command from NetHome server?
I look at "ValueTrigger" that maybe could use for response if in temp example.

Regards
Fred
stefangsbb
Site Admin
Posts: 313
Joined: Sun Nov 30, 2014 2:16 pm

Re: Generats a e-mail when something happend

Post by stefangsbb »

A ValueTrigger would work fine. The way you specify an external script is to first select action "exec" and then press save. After that you can specify an external command or script as action, for example:

Code: Select all

exec,/usr/bin/mail -s "Warning from NetHome" xxxxx@xxxxx.xx < /usr/message.txt
The thing to watch out for is that OpenNetHome is running with a low privileged account, so you have to make sure it has the rights to run the command. You can see some more info in this post: http://nethomeserver.blogspot.se/2014/0 ... ation.html
TotalPE
Posts: 19
Joined: Mon Dec 15, 2014 9:08 am

Re: Generats a e-mail when something happend

Post by TotalPE »

Okay,is there anyone here that can help med and do an newbee guide how to fix the rights for the useraccount to alow it to send mail?

Thanx
/C
rest
Posts: 19
Joined: Wed Oct 21, 2015 4:35 am

Re: Generats a e-mail when something happend

Post by rest »

Hello!

I tried to send an email with the a command but when I add the command line my input is cleared and only "exec,echo " is left. I would like to run this: "echo "Crawl space to cold!" | mail -s "House Control" name@domain.com". What am I doing wrong?

/Reik
Raspberry PI 2 and Tellstick Duo
rest
Posts: 19
Joined: Wed Oct 21, 2015 4:35 am

Re: Generats a e-mail when something happend

Post by rest »

Hello again!

Now I managed to not get an error in ONH but the mail is not sent anyway. I cant find anything in any log file. My command look like this:

ssmtp -t < /etc/opt/nethome/DoorBell.txt

If I use it with brackets [ssmtp -t < /etc/opt/nethome/DoorBell.txt] it will generate an error. It works nice from the commandline. Any idea anyone? Where can I find information about what is going wrong? In the mail logs is nothing...

/Reik
Raspberry PI 2 and Tellstick Duo
rest
Posts: 19
Joined: Wed Oct 21, 2015 4:35 am

Re: Generats a e-mail when something happend

Post by rest »

Hello again!

Is nobody using mail instead of jabber? Which user rights do I need to assign to nethome to be able to send mails?

/Reik
Raspberry PI 2 and Tellstick Duo
rest
Posts: 19
Joined: Wed Oct 21, 2015 4:35 am

Re: Generats a e-mail when something happend

Post by rest »

Hi room!

Now I have been struggling with sending mail for a while. I can't find anything in any log. If the command is not correct I get an error but when I use the correct syntax (works with putty logged in as pi) nothing happens. No error no mail... Does anybody have suggestion where to look?

/Reik
Raspberry PI 2 and Tellstick Duo
rest
Posts: 19
Joined: Wed Oct 21, 2015 4:35 am

Re: Generats a e-mail when something happend

Post by rest »

Another question...

If I would try to login as nethome with putty to test the mail sending. What is is the password of the nethome user?

/Reik
Raspberry PI 2 and Tellstick Duo
stefangsbb
Site Admin
Posts: 313
Joined: Sun Nov 30, 2014 2:16 pm

Re: Generats a e-mail when something happend

Post by stefangsbb »

The nethome user does not have a password, since it is not really intended for a human user. You can switch to the account using the "su" command like this:

Code: Select all

sudo su nethome
Then you will be acting as the nethome user. To go back to the original user you just type:

Code: Select all

exit
rest
Posts: 19
Joined: Wed Oct 21, 2015 4:35 am

Re: Generats a e-mail when something happend

Post by rest »

Thanks Stefan!

I'm not a linux specialist as you see :-). Sending mail as nethome user works fine. How ever, I still don't get any mail from the server. Do you have any suggestion?

/Reik
Raspberry PI 2 and Tellstick Duo
Post Reply