Can cron e-mail HTML?
dan at slightlystrange.org
Sat Jul 14 22:37:06 UTC 2007
Mikhail Teterin wrote:
> I have a script launched from cron every morning, that gets certain data over
> the Internet from a remote computer, compares the new data with that from the
> previous day, and outputs the difference (if any).
> I'm relying on the fact, that cron e-mails me the output of each job.
> However, I modified the script recently to produce the output (if any) in
> HTML, rather than in plain-text format.
> The HTML arrives by e-mail just as well as plain text used to, but no e-mail
> program will render it as such, because neither the cron(8), nor the mail(1),
> which cron uses to send e-mail, creates MIME messages...
> How can I force the ``Content-Type: text/html'' header without hacking cron's
> sources? I'd rather avoid poluting my script with e-mail sending code...
Alter your script to add the 'Content-Type: text/html' header.
> Maybe, cron should apply file(1)-like logic to the e-mailed content?
No, cron doesn't need any knowledge of how to render email. Make sure
the output of your script includes the Content-Type header, which your
mail reader will spot and act upon accordingly. The script itself
doesn't have to send the mail - cron will handle that if there is any
output when it exits, but you /can/ add headers to the message as you need.
Just make sure any custom headers come before the empty line delimiter
between headers and body, and most mail readers should do the right thing.
More information about the freebsd-questions