Community discussions

MikroTik App
 
User avatar
ognjen
newbie
Topic Author
Posts: 35
Joined: Wed Nov 15, 2017 10:31 am
Location: Serbia

Send files via e-mail

Tue Dec 05, 2017 10:52 pm

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 :) )
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).

Code: Select all

: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 :)
 
User avatar
BlackVS
Member Candidate
Member Candidate
Posts: 172
Joined: Mon Feb 04, 2013 7:00 pm
Contact:

Re: Send files via e-mail

Wed Dec 06, 2017 7:42 am

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"
 
User avatar
ognjen
newbie
Topic Author
Posts: 35
Joined: Wed Nov 15, 2017 10:31 am
Location: Serbia

Re: Send files via e-mail

Wed Dec 06, 2017 9:49 am

Tnx bro :)
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. :)
 
User avatar
BlackVS
Member Candidate
Member Candidate
Posts: 172
Joined: Mon Feb 04, 2013 7:00 pm
Contact:

Re: Send files via e-mail  [SOLVED]

Wed Dec 06, 2017 2:22 pm

Hm,
viewtopic.php?t=40650
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...
 
User avatar
ognjen
newbie
Topic Author
Posts: 35
Joined: Wed Nov 15, 2017 10:31 am
Location: Serbia

Re: Send files via e-mail

Wed Dec 06, 2017 4:47 pm

Thank you man! Work fine! :)

Who is online

Users browsing this forum: rogerioqueiroz and 22 guests