Email attachment contents misaligned

Hi All,

I am using mail -s in my shell script to write contents of logfile as the content of my email, and attaching the error_log.txt along with it.
When the email gets sent out, the contents of the attachment error_log.txt is misaligned.

(cat $logfile ;uuencode $error_log.txt error_log.txt ) | mail -s "Update XXX" email@yahoo.com

I tried mutt and see the same issue. Can someone help me how the attachment can be sent out without the contents being misaligned?

Thanks in advance.

Misaligned in what way?

If the contents of the file error_log.txt is as below:
This is test line 1
This is test line 2
This is test line 3
This is test line 4
This is test line 5
This is test line 6
This is test line 7
This is test line 8
This is test line 9
This is test line 10

When the file is sent out as an attachment, the file looks something like
This is test line 1 This is test line 2 This is test line 3 This is
test line 4 This is test line 5 This is test line 6 This is test
line 7 This is test line 8 This is test line 9 This is test line 10

Windows expects lines to end with \r\n. Since the logfile is encoded, the mere act of emailing it doesn't fix this. You can add carriage returns to a file with

sed 's/$/\r/' < inputfile > outputfile
2 Likes

Thank you for the response. I was wondering if there is any option in unix which doest that automatically.
I think I will need to make changed while creating the logfile itself. This is helpful.