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