07.12.2022, 20:01
Hello All,
I am trying to figure out how to send the backup file to more than one recipients using this script without success.
How would this part of the script look like if I want to send the mail to two, three ... recipients?
Any input on the solution would be apreciated.
Regards
I am trying to figure out how to send the backup file to more than one recipients using this script without success.
How would this part of the script look like if I want to send the mail to two, three ... recipients?
Code:
--Recipient for e-mail
to = 'example@hotmail.com'
alias_to = ''
--Subject for e-mail
subjectpart1 = 'MainSL Back-up file'
subjectpart2 = ''
image_description = 'Backup from MainSL'
--Message on bottom of email (will only be showed when client don't understand attachment)
epilogue = 'End of message'
--***********************************************************--
--******************** End of parameters ********************--
--***********************************************************--
--********** DON'T CHANGE ANYTHING UNDER THIS LINE **********--
--***********************************************************--
--Create table to include mail settings
local settings = {
from = from,
rcpt = to,
user = user,
password = password,
server = 'smtp-mail.outlook.com',
port = 587,
secure = 'starttls',
}
--Create attachment
src = 'MainSL_backup-' .. os.date('%Y.%m.%d') .. '.tar.gz'
dst = '/home/ftp/' .. src
-- prepare files for backup
os.execute('sh /lib/genohm-scada/web/general/backup.sh')
-- create archive
os.execute('cd /lib/genohm-scada/storage && tar -c -z -f ' .. dst .. ' ./')
--Create subject
subject = subjectpart1 .. ": " .. src .. " " .. subjectpart2
--Load required modules to send email with attachment
local smtp = require("socket.smtp")
local mime = require("mime")
local ltn12 = require("ltn12")
--Create e-mail header
settings.source = smtp.message{
headers = {
from = '' .. alias_from .. ' ' .. from .. '',
to = '' .. alias_to .. ' ' .. to .. '',
subject = subject
},
Any input on the solution would be apreciated.
Regards