Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 14 Jul 2007 23:17:50 +0100
From:      Daniel Bye <dan@slightlystrange.org>
To:        Mikhail Teterin <mi+kde@aldan.algebra.com>
Cc:        questions@freebsd.org
Subject:   Re: Can cron e-mail HTML?
Message-ID:  <46994B8E.1020108@slightlystrange.org>
In-Reply-To: <200707141603.55899@aldan>
References:  <200707141603.55899@aldan>

next in thread | previous in thread | raw e-mail | index | archive | help
Mikhail Teterin wrote:
> Hello!
> 
> 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.

HTH

Dan



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?46994B8E.1020108>