Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am looking for a way to email the output from various cronjob to specific addresses. The cronjob MAILTO command is too generic. I therefore pipe the output of a job into the mail command.

This works fine except that the output is html encoded and I need to add an Content-Type header to each message.

My version of mail doesn't support the -a flag, which would be perfect. Additionally it seems sendmail isn't available as this is running in a chrooted jail.

share|improve this question
up vote 2 down vote accepted

This solution works as needed.

echo "HTML Message goes here" | mail -s "$(echo -e "This is the subject\nContent-Type: text/html")"

from : http://stackoverflow.com/questions/2591755/how-send-html-mail-using-linux-command-line

share|improve this answer

Pipe it to shell script like this

(echo "Content-type: text/html" ; cat ) | mail recipient
share|improve this answer
    
This solution - in itself correct - seems to prepend the header as part of the content. Piping this into sendmail does result in the desired result. – bas May 14 '12 at 11:42
    
So, is your problem solved? – fstx May 14 '12 at 13:11
    
sorry, no. as i get the header as part of the body – bas May 14 '12 at 14:41

This works on Solaris 10 !

1) Be sure your system has a SMTP Server defined on the /etc/hosts

##############################################
#               SMTP SERVER                  #
##############################################
10.100.231.115    smtpserver.yourdomain.com

2) On the home directory of the user that owns the cron job, create the file: .forward

3) Insert on the file .forward the email address to whom you desire to send the output of the cron Job.

Please Note that I dont think this output is on HTML format ! Just give it a try !

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .