I got the above error when I am executing the bash script with mail command.

In the scripts you use -a in the mail commands to attach the logfile. This does not function and results in an error that an invalid header is being added to the mail.

Looking in the documentation for the mail command, -a is used for adding headers, while -A is used for attaching files.

  -a, --append=HEADER: VALUE append given header to the message being sent
  -A, --attach=FILE          attach FILE

I was using “mail -s “REPORT – $HOSTNAME” -a $TMP_FILE abc@gmail.com and got the above error. Replaced -a with -A and executed the script. It has worked.

Also remember that it depends on the mail software which you are using. It likely depends on implementation, as these are different packages. If the script uses Heirloom-mailx, so -a is correct from that point of view. If you use some other software, just modify the script appropriately.

Leave a Reply