I have a stats program which runs on log files via cron. The stats program can output HTML.

Right now I rely on the MAIL_TO mechanism in the crontab.

MAILTO=my@email.addr
55 23 * * * /usr/bin/htmlstats

The problem is that I want the email sent to display as HTML and not as plain text.

Cron places the following header in the email:

Content-Type: text/plain; charset="UTF-8"

Any idea how I would change this to:

Content-Type: text/html; charset="UTF-8"
link|improve this question

60% accept rate
feedback

3 Answers

up vote 1 down vote accepted

I don't think you can. A solution could be to pipe the output to sendmail or mail, which gives you more control over content type and other headers.

link|improve this answer
Thanks. I gave the piping to mail a go and I'm happy with what I'm seeing. All the best! – Mark L Jan 13 '10 at 11:48
feedback

I put the CONTENT_TYPE="text/plain; charset=utf-8" variable to have my mail in UTF-8.

I think you put CONTENT_TYPE="text/html; charset=utf-8" in crontab to send the HTML in header.

link|improve this answer
So how would I do this? Are these variables CRON is looking for or something? – Mark L Jan 15 '10 at 11:15
OOps sorry, I forgot to say where you put that : add this line in your /etc/crontab. Cron read it and then add the line in the mail header. – Dom Jan 15 '10 at 13:41
feedback

I have the same question. When I pipe to mail (via a script), I still get unformatted html in my mailbox. How do you change the headers?

#!/bin/sh
php -q www/training.php | mail -s testing me@somewhere.com

link|improve this answer
php -q www/training.php | mail -s testing -a 'Content-Type: text/html; charset="UTF-8"' me@somewhere.com – Mark L Mar 4 '10 at 19:53
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.