send log file to email need help to fix

Hay,
I try write script to make log file and send to my email but i dont know ehere the error
its made the file but it cant to send email

my script:

/log print file=([/system identity get name] . “Log-” . [:pick [/system clock get date] 7 11] . [:pick [/system clock get date] 0 3] . [:pick [/system clock get date] 4 6]); \

/tool e-mail send to=“xxx@xxxx.com” subject=([/system identity get name] . " Log " .
[/system clock get date]) file=([/system identity get name] . “-” . [:pick [/system clock get date] 7 11] .
[:pick [/system clock get date] 0 3] . [:pick [/system clock get date] 4 6] . “.txt”); :delay 10;
/file rem [/file find name=([/system identity get name] . “-” . [:pick [/system clock get date] 7 11] .
[:pick [/system clock get date] 0 3] . [:pick [/system clock get date] 4 6] . “.txt”)];
:log info ("System Log emailed at " . [/sys cl get time] . " " . [/sys cl get date])

I fix it now and works fine


/log print file=([/system identity get name] . “Log-” . [:pick [/system clock get date] 7 11] . [:pick [/system clock get date] 0 3] . [:pick [/system clock get date] 4 6]);
/tool e-mail send to=“xxxx@xxxx.com” subject=([/system identity get name] . " Log " .
[/system clock get date]) file=([/system identity get name] . “Log-” . [:pick [/system clock get date] 7 11] .
[:pick [/system clock get date] 0 3] . [:pick [/system clock get date] 4 6] . “.txt”); :delay 10;
/file rem [/file find name=([/system identity get name] . “Log-” . [:pick [/system clock get date] 7 11] .
[:pick [/system clock get date] 0 3] . [:pick [/system clock get date] 4 6] . “.txt”)];
:log info ("System Log emailed at " . [/sys cl get time] . " " . [/sys cl get date])

Thanks…
this script is really helpfull

please also include a command to delete this log from mikrotik memory after emailing this script coz mikrotik have very low memory as u know already..
thanks and regards

You can use the same code that created the file to remove it:
/file remove ([/system identity get name] . “Log-” . [:pick [/system clock get date] 7 11] . [:pick [/system clock get date] 0 3] . [:pick [/system clock get date] 4 6]);

thanks buddy so how would be the full script after adding the line you mentioned. actually i am very new to this…
sorry for taking your time but it will be very helpful for the beginners like me.

i have tried your lines in the end of script is not working… please if this is possible please re edited the whole script
regards

facing an issue in the script…!

my email smtp server settings is ok..mikrotik can send emails except mikrotik logs file it gives error “invalid FROM address”
while it can it can send other emails and delete the created log file from memory. please have a look in snapshot.
error log send via email.PNG

Try entering a from=“name” or email address when you send the message.
/tool e-mail send to=“xxxx@xxxx.com” from=“from@domain.com” subject=…

with tls=yes option including in the script it works…

cheers :slight_smile:

thanks