> On Fri, 2009-10-02 at 21:33 +0300, Jari Fredriksson wrote: >>> On Fri, 2009-10-02 at 20:45 +0300, Jari Fredriksson >>> wrote: >>> >>>> Sendmail command is available with sendmail and postfix >>>> emailers, dunno about others. >>>> >>> You don't need to use sendmail: if the cron job writes >>> anything to stdout (or stderr) this is automatically >>> mailed to root. >>> >>> If you'd rather that mail sent to root comes to you >>> instead, just add a redirection line to /etc/aliases. >>> Don't forget to regenerate the aliases database by >>> running 'aliases' or your redirection won't take effect. >>> >>> >> >> That HTML version needs to add a header for >> Content-Type. That is not possible by just echoing >> somehing, as those go automatically to the body. >> >> The non-html version uses cron's default behaviour, but >> the html version must use sendmail. >> > As crond must also use sendmail to ship any text that is > left for it to deal with and you've already inserted the > MIME header, it seems to me that the HTML processing > would happen anyway, regardless of whether the call to > sendmail was implicit or explicit. Hence I assumed that > you'd just sendmail to avoid using the aliases system. > What did I miss? >
As I have understood it, crond grabs the stdout of the process it runs, and puts that as the "payload" of the email it generates. It writes the mail headers for that mail itself. An email contains two parts, the headers and the body. They are separated by a blank line. First blank line in the stream is the separator. It is not possible to inject headers in the stdout of the cron job, as cron injects the blank line between the body and the headers it generates. If you do not belive, just make a file like this: ------------------- text.sh ---------------------- echo "Content-Type: text/html; charset=\"us-ascii\"" echo "" echo Hello | txt2html --------------------------------------------------- And then command batch text.sh There is a blank line between Content-Type and Hello, but the Content-Type line WILL get to the body, and the html gets injected after it as raw html code, not as html (because the actual content type will be text not html). Cron does NOT allow manipulating the headers. ALL the output is assumed to be payload. If you know better, please post a sample.