LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   How to send a html file from crontab? (https://www.linuxquestions.org/questions/linux-general-1/how-to-send-a-html-file-from-crontab-645906/)

GRD 05-30-2008 03:02 PM

How to send a html file from crontab?
 
I have set one of my cronjob to find big files everyday. I have formatted the output of my cronjob as html log file. I need to forward the output html file to my mail

If I use the following syntax

0 8 * * 1-5 /template.html | mail me@example.com

I get the output with all html tags. I want to see it as a html page without the tags.
Sorry my prev question was not clear
Could someone help me?

acid_kewpie 05-30-2008 03:51 PM

the html way? what's that mean? a text file is just text, you'd need to somehow rewrite it yourself if you want html.

grizly 05-30-2008 06:32 PM

Well, an html file is just text.. to be fair. If I am reading it correctly, you will need to set the right headers in your message.

A few seconds with google gave me this:
Quote:

(
echo "From: you@your_company.com"
echo "To: you@your_company.com"
echo "MIME-Version: 1.0"
echo "Content-Type: multipart/mixed;"
echo ' boundary="PAA08673.1018277622/server.domain.com"'
echo "Subject: Test Message"
echo ""
echo "This is a MIME-encapsulated message"
echo ""
echo "--PAA08673.1018277622/server.domain.com"
echo "Content-Type: text/html"
echo ""
echo "<HTML>
<BODY bgcolor=gray>
<blockquote><font color=red>Test</font> <font color=white>Message</font> <font color=blue>Body</font></blockquote>
</body>
</html>"
echo "--PAA08673.1018277622/server.domain.com"
) | sendmail -t
PS: The PAA08673.1018277622 part, is just a random string in this message, something unique to form a boundary. Save that as a script, and call it from cron.

garyalex 06-04-2008 03:18 AM

Also check out Nail, a replacement for mailx which I use as it has a lot more features.


All times are GMT -5. The time now is 10:12 PM.