This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm whether you accept or reject these cookies being set.

e-mail triggering
#1
Hi,

I'm trying to trigger sending mail by value =1. would that be correct script?

-- make sure mail settings are set in user function library before using this function
subject = 'THERE IS ALARM'
message = 'THERE IS AN ALARM IN THE SYSTEM- PLEASE LOG IN TO VISUALISATION AND CHECK ALARM PAGE'
mail('test@mail.com', subject, message)

--trigger function

value = event.getvalue()

if (value ==1) then

  send (mail)
 
end
Reply
#2
For boolean data type the value can be either true or false. You can simply write it like this:
Code:
value = event.getvalue()

if value then
  send (mail)
end
Reply
#3
Hi,

I've set as advised and made sure the object in of the boolean type, but no e-mail is being sent.

The whole trigger even looks like this:

-- make sure mail settings are set in user function library before using this function
subject = 'THERE IS ALARM'
message = 'THERE IS AN ALARM IN THE SYSTEM- PLEASE LOG IN TO VISUALISATION AND CHECK ALARM PAGE'
mail('mail to which e send', subject, message)

--trigger function

value = event.getvalue()

if value then
send (mail)
end
Reply
#4
Change to variable as needed. If it does not work then check what you get in Logs tab.

Code:
to = 'user@example.com'
subject = 'THERE IS ALARM'
message = 'THERE IS AN ALARM IN THE SYSTEM- PLEASE LOG IN TO VISUALISATION AND CHECK ALARM PAGE'

value = event.getvalue()
if value then
  res, err = mail(to, subject, message)
  log(res, err)
end
Reply
#5
That's the fault from logs:

* arg: 1
* nil
* arg: 2
* string: 535-5.7.8 Username and Password not accepted. Learn more at
535 5.7.8 https://support.google.com/mail/?p=BadCredentials o1sm5514363wrm.66 - gsmtp

less secure apps are activated - just in case you might ask
Reply
#6
Did you setup email settings in Common functions?
------------------------------
Ctrl+F5
Reply
#7
I've got it working - just retyped all instead copy paste and is working

Now, one more question - if I wished to have more users then what would I need to do? add more mail addresses in the line 'to' i.e.

to = 'user1@mail.com' ; 'user2@mail.com'
Reply
#8
Like this:
Code:
to = { 'user1@mail.com', 'user2@mail.com' }
Reply


Forum Jump: