Error sending e-mail: error handling file

What this error means: “Error sending e-mail: error handling file”?

I have script that creates backup both command and binary. Command goes through email with no issues. For binary file I get this error.

to access backup files sensitive policy is required

Thanks, it works now. I guess this came with Mikrotik update, because the same script worked fine before.

This behavior is since v4.x

Hi,

i got the same error, the email can go fine when has no attachement, the snesitive policy is set, the debug log stucks in

RCV: 354 enter mail, end with “.” on a line by itself,
error sending email, abnormal termination timeout

when i send the email without backup it works fine, also i try to send the backup in the /tool email, and stuck in the same place
thanks

Hello, i have the same problem:
sometimes it works, sometimes the logging says: Error sending e-mail : error handling file.
Is there someone who can explain whats happen?

/export 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]);
/tool e-mail send to=“x@X.nl” subject=([/system identity get name] . " Script " .
[/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] . “.rsc”); :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] . “.rsc”)];
:log info ("System Script emailed at " . [/sys cl get time] . " " . [/sys cl get date]);

the problem is here:

/export file="filename.rsc"

Create filename.rsc.in_progress
(or similar, but not just filename.rsc).

/tool e-mail file=filename.rsc

Try to get file filename.rsc
BUT this file MAY BE still named with .in_progress postfix.

So, add :delay 2s; before accessing this file:

/export file=filename.rsc

# wait export finished
:delay 2s; 

/tool e-mail file=filename.rsc

I’m having a similar issue
I’m running my script as an “full” user
The script has sensitive policy enabled, yet I cannot get it to send the email with the file attached

:global BACKUPFILE [([/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])]
:global TO [(“email@gmail.com”)]
:global SUBJECT [("[Mikrotik] ". [/system identity get name])]
:global BODY [(“Backup file”)]
/system backup save name=$BACKUPFILE
:delay 5
/tool e-mail send to=$TO subject=$SUBJECT body=$BODY file=$BACKUPFILE
:log info ("System Backup emailed at " . [/sys cl get time] . " " . [/sys cl get date])
:delay 10
/file remove $BACKUPFILE

name=“EmailBackup” owner=“owner”
policy=ftp,reboot,read,write,policy,test,password,sniff,sensitive
last-started=oct/02/2017 09:52:36 run-count=105

We got the same problem when sending e-mail with file attached its not sending.
Mail flow without file attached is working perfect.

Got the correct policy’s enabled also, the logging show:

Error sending e-mail <[Mikrotik] cr2>: error handling file

After doing some more digging around I found that if I specify the filename to use instead of using a variable, then I do not get the file handling error.
Could this be a bug in the OS?

Find the solution

I changed the line
/tool e-mail send to=$TO subject=$SUBJECT body=$BODY file=$BACKUPFILE
to
/tool e-mail send to=$TO subject=$SUBJECT body=$BODY file=[$BACKUPFILE]

Just put the file variable in

This solution is still not working:


Error sending e-mail <[Mikrotik]>: error handling file

Just add a little delay after the /tool email line

Adding delay work for me. Thanks

This works for me:

/local filename ([/system identity get name] . "_" . [:pick [/system clock get date] 0 3] . "-" . [:pick [/system clock get date] 4 6] . "-" . [:pick [/system clock get date] 7 11] . ".rsc");

/export file=$filename;
:delay 5s;
/tool e-mail send to="support@mycompany.com" subject="$[/system identity get name] configuration export" \
body="Mikrotik $[/system identity get name]: configuration file on $[/system clock get date] - $[/system clock get time] --- $filename" \
file=$filename;
:delay 45s;
/file remove $filename;