Format text in mail attachments

Hi Gurus,

I am working on a script that sends a text file attachment on mail from unix server to my widows outlook mail box.

When i see the text file in UNIX it is perfectly formatted but when i open the same file in the mail, it looks weird as the next line is added to the same line.

For example, in unix the file looks like,

ABC#DEF
GHI#JKL
MNO#PQR

But the mail attachment looks like

ABC#DEFGHI#JKLMNO#PQR

The command i used to send mail from UNIX is

(printf "%s\n%s\n" "`cat bodyofmail.txt`";unix2dos mytext.txt | uuencode mytext.txt mytext.txt) | mailx -s "subject" me@mail.com

Please help me out in fixing this.

I think all it needed was a little ux2dos (unix2dos) on your file before sending it to mailx (why not, using a pipe...)

Sorry... didnt see you were using unix2dos... but not clear what you are doing...

cat file_to_send | ux2dos | mailx -s "ljkdfj"  mail@address

should be enough ( well it works for me anyway...)

Hi,

Thanks for the reply.

Your command worked but it sent the text file in the body of the message itself.

I need the text file to be send as an attachment in the mail.

So your first idea is the good one except of unix2dos... Are sou sure of the syntax? I know there are variations, it goes to convert the given file - To STDOUT or outfile to convert on the fly the inputfile...

What is you OS (version)? Have you tried configuring a .mailrc file?

Hi,

I am getting the mail with attachment using the command that i used. But it is not formatted.

I have used unix2dos as i am sending mail from the Linux x86_64 box to my mail account. Also the mail sending option is already configured as i am getting mails from my other scripts.

I remember long ago a similar case with uuencode...
Have you in your home directory a .mailrc file?
If not create one and put in it:

set crt=21
set encoding=8bit
set charset=iso-8859-1
# set mimeheader=yes

I have added the mailrc file but still i am getting the same attachment

linux->more .mailrc
set crt=21
set encoding=8bit
set charset=iso-8859-1
# set mimeheader=yes

When i copy the contents from notepad to word, i am getting it aligned line after line. But only i notepad i am getting it in the same line.

---------- Post updated at 10:23 AM ---------- Previous update was at 10:15 AM ----------

I am getting special characters in the attachment like a small rectangular box. Would that be the issue ?

Dont know...
I would try to unix2dos the file before, remove that part from your command line, so it is already converted before the uuencode, give it a try?

Ever considered to use sendmail -t ?