Multiple email recipients with one call to email() in Lua scripting


#1

Is there any way to address one email to multiple recipients with one call to email() in Lua scripting?

Example:

local myAddresses = 'user1@example.com, user2@example.com'
local mySubject = 'Update: Something Happened'
local myMessage = 'This is what happened'

email(myAddresses, mySubject, myMessage)

Am I doing something wrong? Or is this somehow in violation of the email dispatch limit for a portal and therefore not allowed?


#2

Unfortunately it’s not possible to send an email dispatch to multiple recipients with a single call to the email dispatch function.

I would suggest using a function like this to emulate this behavior.

local myAddresses = {'user1@example.com', 'user2@example.com'} -- now an array
local mySubject = 'Update: Something Happened'
local myMessage = 'This is what happened'

local function email_multi(recipients, subject, message)
  for _, address in pairs(recipients) do
    dispatch.email(address, subject, message)
  end
end

email_multi(myAddresses, mySubject, myMessage)

#3

Ok, thanks for clearing that up for me.