Вы могли бы позволить mailx
справиться со всем:
echo ${BODY} | mailx -r "mail@mail.com" -s "Export csv file" -A /data/${FILE} "mail2@mail2.hr"
При необходимости вы можете использовать --encoding
для установки кодировки и следующих флагов для определения вложенного файла (установите их перед-A
).
--content-filename=NAME
set the Content-Disposition filename parameter for the next --attach option
--content-name=NAME
set the Content-Type name parameter for the next --attach option
--content-type=TYPE
set content type for subsequent --attach options