LogicMachine Forum
Email Multi destination address - Printable Version

+- LogicMachine Forum (https://forum.logicmachine.net)
+-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1)
+--- Forum: Scripting (https://forum.logicmachine.net/forumdisplay.php?fid=8)
+--- Thread: Email Multi destination address (/showthread.php?tid=2743)



Email Multi destination address - Frank68 - 23.07.2020

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


RE: Email Multi destination address - Erwin van der Zwart - 23.07.2020

Hi,

Try:

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

BR,

Erwin


RE: Email Multi destination address - Frank68 - 24.07.2020

(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


RE: Email Multi destination address - fleeceable - 28.07.2020

I'm using script like this and it works even if one of the emails are empty.
Code:
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



RE: Email Multi destination address - Erwin van der Zwart - 28.07.2020

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


RE: Email Multi destination address - admin - 28.07.2020

@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.


RE: Email Multi destination address - Erwin van der Zwart - 29.07.2020

(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 (: