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
#1
Hi
I test and woks fine the mail for send alarm , is possible send email more to one address in the same time ?

Best regards

Thank's
Reply
#2
Hi,

Try:

to = {"recipient1@mail.com","recipient2@mail.com","recipient3@mail.com"}

BR,

Erwin
Reply
#3
(23.07.2020, 16:19)Erwin van der Zwart Wrote: Hi,

Try:

to = {"recipient1@mail.com","recipient2@mail.com","recipient3@mail.com"}

BR,

Erwin
I have tested but not work , for one dest work

I use this for send mail

-- INDICAZIONI COMUNI
-- get current data as table
now = os.date('*t')
TS=' del '..now.day..'/'..now.month..'/'..now.year..' alle '..now.hour..':'..now.min..':'..now.sec
Dest  ='claudio@ciemme.com'

value_01 =grp.getvalue('32/1/58')
    if (first_loop == 1) then
      if (value_01 ~= last_01) and (value_01 == true) then
          subject = 'ON ALM'
    message = 'ON MESSAGE' .. TS
          mail(Dest, subject, message)   
          alert(message)
        elseif (value_01 ~= last_01) and (value_01 == false) then
          subject = 'OFF ALM'
    message = 'OFF MESSAGE' .. TS
          mail(Dest, subject, message)   
        end
    end
    last_01=value_01

first_loop = 1

tank's in advantage
Reply
#4
I'm using script like this and it works even if one of the emails are empty.
Code:
123456789101112131415161718192021222324252627282930313233
alarm = grp.getvalue('10/0/31') email1 = grp.getvalue('32/6/1') email2 = grp.getvalue('32/6/2') email3 = grp.getvalue('32/6/3') if email1~='' then   if email2~='' then     if email3~='' then       emails = {email1,email2,email3}     else       emails = {email1,email2}     end   else     emails = {email1}   end else   if email2~='' then     if email3~='' then       emails = {email2,email3}     else       emails = {email2}     end   else     if email3~='' then       emails = {email3}     end   end end   if alarm 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!') end
Reply
#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:
123456789101112131415
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
#6
@Erwin this regexp does not handle domain part with multiple dots like .co.uk, it also does not handle valid characters like hyphens and underscores.
Reply
#7
(28.07.2020, 15:09)admin Wrote: @Erwin this regexp does not handle domain part with multiple dots like .co.uk, it also does not handle valid characters like hyphens and underscores.

Thanks! Updated (:
Reply


Forum Jump: