I have a cron to execute php files and then mails me the output. This works fine. My question is I want cron to email me the output in HTML. Currently it is just plain text.

I know when I use mail to use the code below and the email is formatted correctly.

$headers = “From: $from\r\n”;
$headers .= “Reply-To: $email \r\n”;
$headers .= ‘MIME-Version: 1.0’ . “\r\n”;
$headers .= “Content-Type: text/html; charset=‘iso-8859-1’\n”;
$headers .= “X-Mailer: PHP/”.phpversion();

So, the question is, how can I get cron to do that? Or put that information in the cron headers?



I’m not shure if I understand your problem correctly. But this header is not the header of the script, but of the mail you are sending. So you just have to add the headers to the mail function. Like this (copied from

// To send HTML mail, the Content-type header must be set
$headers = ‘MIME-Version: 1.0’ . “\r\n”;
$headers .= ‘Content-type: text/html; charset=iso-8859-1’ . “\r\n”;

// Additional headers
$headers .= ‘To: Mary, Kelly’ . “\r\n”;
$headers .= ‘From: Birthday Reminder’ . “\r\n”;
$headers .= ‘Cc:’ . “\r\n”;
$headers .= ‘Bcc:’ . “\r\n”;

// Mail it
mail($to, $subject, $message, $headers);

Hope this works


Thanks for your help. Maybe I did not make my original post clear. When I get the email from cron it is not formatted for HTML. What I am looking for is cron to run the script and email me the output in HTML format not in the test format as it is currently doing.