linux - Emailed output of 'cat' removes random spaces and newlines -
first time posting here.
have following file , contents:
linux$ cat file.txt line 1 line 2 line 3 line 4
i have following code:
output=$(cat file.txt) echo "$output" | mail -s "[test]" -a test.txt host@domain.com
i send file attachment debugging purpose. problem encounter email body containing output of 'cat file.txt' looks this:
line 1
line 2 line
3 line 4
the attached file contains correctly formatted output of 'cat file.txt', no characters, newlines, spaces added or removed.
what might causing this? appreciate help!
i think need specify in format email content should sending out.
utf-8 great option since it's world wide almost.
this might helpful:
cat file.txt | mail -s '$(echo -e "test\ncontent-type: text/html")' -a test.txt host@domain.com
or charset
cat file.txt | mail -s '$(echo -e "test\ncontent-type: text/html; charset="us-ascii")' -a test.txt host@domain.com
or without unix pipeline
mail -a 'content-type: text/plain; charset="us-ascii"' foo@bar.com < file.txt
more info can found here.
it depends on version of mail.
hope helpful
Comments
Post a Comment