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 that you accept these cookies being set.

Email Multi destination address
#5
Hi,

Here is a improved version of your script, sorry i couldn't ignore if else then's (:

It also performs a regex on your mail addresses to be sure they are valid. (~="" does not say anything)
Code:
alarm = grp.getvalue('10/0/31')
if alarm then
  email1 = grp.getvalue('32/6/1')
  email2 = grp.getvalue('32/6/2')
  email3 = grp.getvalue('32/6/3')
  emails = {}
  if email1:match('[%w]*[%p]*%@+[%w]*[%.]?[%w]*') then table.insert(emails, email1) end
  if email2:match('[%w]*[%p]*%@+[%w]*[%.]?[%w]*') then table.insert(emails, email2) end
  if email3:match('[%w]*[%p]*%@+[%w]*[%.]?[%w]*') then table.insert(emails, email3) end
  if #emails > 0 then
    mail(emails, 'MAJA valvekeskuse alarm', 'Tere! <br><br>Valvekeskuse poolt on tuvastatud MAJA häire! Palun vaadake täpsemalt visualiseeringust.<br><br><br><i>See email on genereeritud automaatikasüsteemi poolt. Palun mitte sellele emailile vastata!')
  else
    log('no valid mail adresses found')
  end
end
BR,

Erwin
Reply


Messages In This Thread
Email Multi destination address - by Frank68 - 23.07.2020, 14:36
RE: Email Multi destination address - by Erwin van der Zwart - 28.07.2020, 15:03

Forum Jump: