Search code examples
mailx

Mail the content of a plain text file from the shell


I'm using the following command to email the content a file from the shell:

mail -s 'Subject' to@domain.ext < file.txt

I always got a plain text mail with empty body and an attachment named "Subject.txt.dat" containing the content of file.txt.

I would like to get a plain text mail with the content of file.txt as body, and no attachments.

All tutorials I've found on Google suggests to use such command but in my case is not working as expected.

I'm on CentOS 6 and

man mail

shows it is using mailx.


Solution

  • This page seems to match your problem and offers some solutions:

    https://access.redhat.com/solutions/1136493

    • Remove non-US-ASCII or non-printable characters from the e-mail text, or
    • use sendmail, which will accept and forward DOS-style formatted text, or
    • use mutt, which provides more funcionality regarding how the e-mail should be sent.