Send files via e-mail

Hello,
I have something what can’t to do.
I want to send backup & log files via one e-mail but don’t know what to write in script.
When use only one file, work fine but wih 2x don’t work. (I can configure script to send file by file with two e-mails, but batter is send two files with one mail :slight_smile: )
Btw, don’t have log info from script in log when try to run this script (I think is that becouse have some error).
So, my script is down and below is copied part of the script where is th problem (Marked RED).
:log info “Backup Configurations”
:global backupconf ([/system identity get name] . “-” . [/system clock get time] . \ “.” “CONF”)
/system backup save name=$backupconf
:log info “Backup pausing for 2s”
:delay 2s

:log info “Backup log”
:global backuplog ([/system identity get name] . “-” . [/system clock get time] . \ “-” “LOG”)
/log print file=$backuplog
:log info “Backup log pausing for 10s”
:delay 10
:log info “Backup being emailed”

/tool e-mail send to=“ognjen.stanisavljevic@mega.rs” subject=([/system identity get name] . “-” . [/system clock get time] .
" Backup Configuration & Log - SBB-Optic") from=mikrotik@mega.rs file=$backupconf file=$backuplog server=mail.mega.rs

:log info “backup LOG finished"here:
/tool e-mail send to=“ognjen.stanisavljevic@mega.rs” subject=([/system identity get name] . “-” . [/system clock get time] .
" Backup Configuration & Log - SBB-Optic”) from=mikrotik@mega.rs file=$backupconf file=$backuplog server=mail.mega.rs

If someone have solution, post here. I would like to hear your thoughts :slight_smile:

https://wiki.mikrotik.com/wiki/Manual:Tools/email

file (File[,File]; Default: ) List of the file names that will be attached to the mail separated by comma.
I.e. not “file=AAA file=BBB” but “file=AAA,BBB”

Tnx bro :slight_smile:
Yes, that can what u write, but can’t when use: file=$backuplog,$backupconf .
This problem will be visible if u put 2x file with $.

If you can resolve problem, i will follow instruction. :slight_smile:

Hm,
http://forum.mikrotik.com/t/multiple-files-in-one-e-mail/36712/1
It is crazy due to in wiki it is clearly said that it should be “list of comma separated”…
BUT!!!

:local backupconf "$[/system identity get name]-$[/system clock get time]-CONF.backup"
:local backuplog "$[/system identity get name]-$[/system clock get time]-LOG.txt"

:log info "Backup Configurations $backupconf"
/system backup save name=$backupconf
:log info "Backup pausing for 2s"
:delay 2s

:log info "Backup log $backuplog"
/log print file=$backuplog
:log info "Backup log pausing for 10s"
:delay 3
:log info "Backup being emailed"

:local files {$backupconf;$backuplog}
/tool e-mail send to="vvs@somewhere.com" subject="$[/system identity get name]-$[/system clock get time] Backup Configuration & Log - SBB-Optic" file=$files

:log info "backup LOG finished"

I just put myself on place of developer and imagine how I would passed few files…

Thank you man! Work fine! :slight_smile: