This is an old revision of the document!


Encoding problems with using mail linux utility to send reports

Recently we faced with encoding problem with using mail linux utility.

Below is a part of simple script that is using for send report with using cron.

 if [ $err_f -ne 0 ]
   then
    echo "Backups directories $dirr_nn on rum-gpfsstorage0 were failed.
      See logs $log_nn  on rum-gpfs-b1.scanex.ru in /scripts/logs/ . Backups of other directories were successfull." | mail -r "backup-rum-gpfs@scanex.ru" -s "backup gpfs $dirr_nn directories failed" adm@scanex.ru
    else
    echo  "Backups all gpfs directories were successfull." |    mail -r "backup-rum-gpfs@scanex.ru" -s "backups all gpfs directories were successfull" adm@scanex.ru
    fi

When it started by cron all body text was unreadable. We looked at mail header:

 User-Agent: Heirloom mailx 12.4 7/29/08
 MIME-Version: 1.0
 Content-Type: application/octet-stream
 Content-Transfer-Encoding: 8bit

But when we started this script manualy all ware right. Mail header below:

 User-Agent: Heirloom mailx 12.4 7/29/08
 MIME-Version: 1.0
 Content-Type: text/plain; charset=utf-8
 Content-Transfer-Encoding: 8bit

To change content type to text/plain; charset=utf-8 we just add line to the begining of script:

export LANG=en_US.UTF-8
en/jobs/bashlinuxmail_encoding.1424433677.txt.gz · Last modified: 2015/02/20 15:01 by admin
Recent changes RSS feed Debian Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki