From owner-freebsd-questions@FreeBSD.ORG Sat Jul 14 22:37:05 2007 Return-Path: X-Original-To: questions@freebsd.org Delivered-To: freebsd-questions@FreeBSD.ORG Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id E060316A408 for ; Sat, 14 Jul 2007 22:37:05 +0000 (UTC) (envelope-from dan@slightlystrange.org) Received: from catflap.slightlystrange.org (cpc5-cmbg1-0-0-cust497.cmbg.cable.ntl.com [86.6.1.242]) by mx1.freebsd.org (Postfix) with ESMTP id 1776013C4A5 for ; Sat, 14 Jul 2007 22:37:03 +0000 (UTC) (envelope-from dan@slightlystrange.org) Received: by catflap.slightlystrange.org (Postfix, from userid 106) id E313B61AC; Sat, 14 Jul 2007 23:17:54 +0100 (BST) Received: from stoopid.slightlystrange.org (stoopid.slightlystrange.org [10.1.3.142]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by catflap.slightlystrange.org (Postfix) with ESMTP id 559096108; Sat, 14 Jul 2007 23:17:54 +0100 (BST) Message-ID: <46994B8E.1020108@slightlystrange.org> Date: Sat, 14 Jul 2007 23:17:50 +0100 From: Daniel Bye User-Agent: Thunderbird 2.0.0.4 (Macintosh/20070604) MIME-Version: 1.0 To: Mikhail Teterin References: <200707141603.55899@aldan> In-Reply-To: <200707141603.55899@aldan> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Cc: questions@freebsd.org Subject: Re: Can cron e-mail HTML? X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 14 Jul 2007 22:37:06 -0000 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