I use multiple SpaceLynk's and have tried your example script to backup and mail automaticlly.
But everytime at execution I get this error message and no Mail is send:
25.06.2016, 08:55 (This post was last modified: 25.06.2016, 08:56 by Erwin van der Zwart.)
Hi Habib,
The new FW 1.2 for SL and 1.5 for HL requires a change in the mail script.
1) Make sure you have changed your g-mail account to enable HL to send e-mail on https://www.google.com/settings/security/lesssecureapps
2) Change user and password in the script
3) Change sender and receiver details in the script
25.06.2016, 15:23 (This post was last modified: 25.06.2016, 15:27 by Habib.)
Hi Erwin,
many thanks for the script. I had a little bit trouble with copy&paste from this forum page to my script page, but now it works after correction of all CR and LR signs.
Last thing is, the script has trouble with the @ and SPACE Sign in Alias variable. It's only cosmetic.
26.06.2016, 00:16 (This post was last modified: 26.06.2016, 00:17 by Erwin van der Zwart.)
HI Habib,
Your welcome (:
The problem with copy paste is Chrome issue, use another browser to avoid this or paste the code into MS word and copy it again before pasting it into your controller.
Alias is used for name instead of email address and it should be possible to have a space, I use it with my name so there are multiple spaces in my alias and that works normal. Never tested with @ ...
I tried copy&paste with Safari in OSX (an Webkit Browser like Chrome) and in my VM with Windows 7 and Firefox 47.0.
I've sent you an PM with screenshots for viewing the Mail Header in Outlook 2016 (Mac). It's only for understanding my fail.
(25.06.2016, 08:55)Erwin van der Zwart Wrote: Hi Habib,
The new FW 1.2 for SL and 1.5 for HL requires a change in the mail script.
1) Make sure you have changed your g-mail account to enable HL to send e-mail on https://www.google.com/settings/security/lesssecureapps
2) Change user and password in the script
3) Change sender and receiver details in the script
--***************************************************************----** Email backup as attachment created by Erwin van der Zwart **----****** For HL from FW 1.5 and SL from FW 1.2 with NGINX *******----***************************************************************----********************* Start of parameters *********************----***************************************************************----Gmail (smtp) username !IMPORTANT!user = 'YOUR EMAIL ADRESS'--Gmail (smtp) password !IMPORTANT!password = 'YOUR PASSWORD'--Sender for e-mailfrom = '<' .. user .. '>'alias_from = 'YOUR ALIAS'--Recipient for e-mailto = '<receiver@domain.com>'alias_to = 'receiver'--Subject for e-mailsubjectpart1 = 'Back-up file'subjectpart2 = 'automaticly send by homeLYnk'--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 settingslocalsettings = {
from = from,
rcpt = to,
user = user,
password = password,
server = 'smtp.gmail.com',
port = 465,
secure = 'sslv23',
}
--Create attachment inside FTP serverid = 'HL_192.168.0.10-'-- Give here your details of your HLsrc = 'backup-'..id..os.date('%Y.%m.%d.%H.%M.%S') .. '.tar.gz'dst = '/home/ftp/' .. src-- prepare files for backupos.execute('sh /lib/genohm-scada/web/general/backup.sh')
-- create cleanup archiveos.execute('cd /lib/genohm-scada/storage && tar -c -z -f ' .. dst .. ' ./')
-- post-backup cleanupos.execute('cd /lib/genohm-scada/storage && rm -rf user userlib.luas blockly.luas initscript.lua helpers.js genohm-scada.config filter*')
--Create subjectsubject = subjectpart1 .. ": " .. src .. " " .. subjectpart2--Load required modules to send email with attachmentlocalsmtp = require("socket.smtp")
localmime = require("mime")
localltn12 = require("ltn12")
--Create e-mail headersettings.source = smtp.message{
headers = {
from = '' .. alias_from .. ' ' .. from .. '',
to = '' .. alias_to .. ' ' .. to .. '',
subject = subject
},
--Load attachment inside body body = {
preamble = "",
[1] = {
headers = {
["content-type"] = 'application/x-7z-compressed',
["content-disposition"] = 'attachment; filename="'..src..'"',
["content-description"] = '.. src ..',
["content-transfer-encoding"] = "BASE64",
},
body = ltn12.source.chain(
ltn12.source.file(io.open(dst, "rb")),
ltn12.filter.chain(
mime.encode("base64"),
mime.wrap()
)
)
},
epilogue = epilogue
}
}
--Send the emailr, e = smtp.send(settings)
--Create alert when sending gives an error with error messageif (e) thenlog (e)
log (r)
alert("Could not send email: ", e, "\n")
endlog("Mail Send")
--Delete created backup file from ftp folder inside HLos.remove(dst)
BR,
Erwin van der Zwart
Hi Erwin,
I am trying to send backup by email with the scritp you mention, but google throws me an error (I send the capture). My HL is in the latest version, both soft and hard.
Maybe the solution is to change the mail provider? Any suggestions in the scritp to keep it?
Thank you very much in advance, I learn a lot here :-)
I tried the extension change or without it, but Mr. Google is a smart guy ...
Same mistake.
Any suggestions that work well to change the mail provider?