Sign up ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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.

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"
share|improve this question

4 Answers 4

up vote 4 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.

share|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
The CONTENT_TYPE variable solution mentioned in another answer seems to work at least in some cron versions. –  Peter Eisentraut Oct 15 '13 at 18:19

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

Put CONTENT_TYPE="text/html; charset=utf-8" in /etc/crontab to send the mail in HTML.

share|improve this answer
This is awesome... can confirm it works on Ubuntu 14.04.2. –  billynoah Sep 18 at 22:25

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?

php -q www/training.php | mail -s testing

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

YES, you can.

<?php exec('(  echo "test<br>créer un mail"| mail -s "SUBJECT" -a "Content-Type: text/html; charset=UTF-8" '.$receiver.' -- -f '.$sender.' ) &> /dev/null &'); ?>
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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