"Failed to send email: 'ascii' codec can't encode character" in 11.3 from cron job.

Cartesio

Dabbler
Joined
Dec 9, 2018
Messages
16
Hello,

I have a cron job to download backup files from a remote server and store a copy on a FreeNAS box, using this script:

wget -nv --no-check-certificate --ftp-user xxxxxxxx --ftp-password xxxxxxxxxxxxxxxxxx -P /mnt/main/private/backups/mail -N "ftps://xxxxxx.xxxxxxxx.xxx/mail/*"

Both "Hide standard output" and "Hide standard error" are disabled so I can get a log of what happened. The script runs correctly, but the alert sent via email throws this error:

Error: [EFAULT] Failed to send email: 'ascii' codec can't encode character '\u2018' in position 375: ordinal not in range(128)

I believe that's something in the wget output which is not ASCII7 only. If for whatever reason in 2020 something can't accept unicode data correctly, there are ways to turn them into ASCII7 data even in a lossy way, i.e. replacing characters with ? or the like, instead of just throwing an error. If that's Pyrhon you could use .encode("ascii", errors="ignore") or
.encode("ascii", errors="replace") - but supporting UTF-8 would be a far better solution.

PS: --no-check-certificate is there because it looks the certificate set in FreeNAS are not used by the OS itself and other software running on it. But that's another issue.
 

HomeBoy38

Dabbler
Joined
Sep 27, 2018
Messages
15
Hi,

I have just migrated to 11.3 on Saturday and I am experiencing the same issue. Checking the /var/log/maillog error, I found this thread...
I will investigate on the issue and let you know if I come to any solution/workaround

EDIT : as the issue was an accentuated character in my report email, I changed the text in order to have no accent left.
 
Last edited:
Top