3

I have a command I have been using to send emails with an attachment and a message body

(cat msg_file.txt; uuencode file.csv file.csv) | mail -s "subject" user@mail.com

as soon as I add the -a option for sending headers in order to send an HTML file

(cat msg_file.html; uuencode file.csv file.csv) | mail \
 -a "MIME-Version: 1.0" \
 -a "Content-type: text/html; charset=iso-8859-1" \
 -s "subject" user@mail.com

The HTML file will work but now the attachment does not. Instead I get a long string of text that is mostly not human readable and isn't any help, I have no idea what it means.

I have tried variations on how I am reading the email body to stdin like

uuencode file.csv file.csv | mail \
 -a "MIME-Version: 1.0" \
 -a "Content-type: text/html; charset=iso-8859-1" \
 -s "subject" user@mail.com < msg.html

But still no luck. I do not know a lot about headers so I may be over looking something to do with the headers? Does anyone know how to alter the above commands to send an attachment along with the HTML message body? Or will I have to use another method?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.