How to fix mailx sends text body as an attachment
Due to non-US-ASCII or non-printable characters, when mailx processes the input, it correctly sets the MIME type to application/octet-stream when non-US-ASCII or non-printable characters are present. Non-Unix text files that use carriage return (^M, \r) characters in addition will be treated as binary data; to send such files as text, strip these characters e. g. by my-script.sh | tr -d '[\015\200-\377]' | mailx -s "my mail" ...