Linux How would i mail in html format?(Formatting Help)

Compiler

Disciple
I have written a scripts that checks the load average of server and if it is more than 5 it send a mail describing Current Load Average and High CPU/RAM processes .

The problem is I want to send these information in html form .I have done necessary coding to do the same but whenever i try to include the output of following It doesnt seems to be properly formatted.

Code:
echo "Top 10 CPU Utilized Processes" >> /tmp/Load_Average_Check.html
ssh -Tqn $1 ps auxf | sort -nr -k 3 | head -10 >> /tmp/Load_Average_Check.html
echo "-------------------------------------" >> /tmp/Load_Average_Check.html
echo "Top 10 Memory Utilized Processes" >> /tmp/Load_Average_Check.html
ssh -Tqn $1 ps auxf | sort -nr -k 4 | head -10 >> /tmp/Load_Average_Check.html
Output is as below.
Code:
******************************************************* Top 10 CPU Utilized Processes root 28679 2.5 0.0 34916 6688 ? Sl 00:05 20:59 \_ /usr/lib/xen/bin/qemu-dm -d 387 -domain-name XXXXXX -videoram 4 -k en-us -vnc 0.0.0.0:0,password -vncunused -vcpus 1 -boot c -localtime -serial pty -acpi -usbdevice tablet -net nic,vlan=1,macaddr=00:16:3E:67:92:4F,model=rtl8139 -net tap,vlan=1,ifname=tap387.0,bridge=XXXX -M xenfv root 32002 2.3 0.0 34712 4784 ? Sl Apr06 283:01 \_ /usr/lib/xen/bin/qemu-dm -d 372 -domain-name XXXXXXXX -videoram 4 -k en-us -vnc 0.0.0.0:0 -vncunused -vcpus 2 -boot c -localtime -serial pty -acpi -usbdevice tablet -net nic,vlan=1,macaddr=00:16:3E:19:32:09,model=rtl8139 -net tap,vlan=1,ifname=tap372.0,bridge=XXXX -M xenfv root 26933 1.9 0.0 0 0 ? Z 13:36 0:00 \_ [python] root 1815 1.9 0.0 35020 6852 ? Sl Feb17 1553:59 \_ /usr/lib/xen/bin/qemu-dm -d 261 -domain-name XXXXXX -videoram 4 -k en-us -vnc 0.0.0.0:0,password -vncunused -vcpus 2 -boot c -localtime -serial pty -acpi -usbdevice tablet -net nic,vlan=1,macaddr=XXXXXX,model=rtl8139 -net
Its so difficult to understand when i mail the information in plain text i can see the output properly formatted.

Is there any way i can send some part of script output in html while other in plain text ?
I hope i m not confusing ...
 
Add these details in your headers

MIME-Version: 1.0

Content-Type: text/html; charset=ISO-8859-1

<html><body>

Email

</body></html>

This will send it as HTML.
 
nitant said:
Add these details in your headers

MIME-Version: 1.0

Content-Type: text/html; charset=ISO-8859-1

<html><body>

Email

</body></html>

This will send it as HTML.

I m getting the output in html format .The only problem is that command ouput such as

Code:
ssh -Tqn $1 ps auxf | sort -nr -k 4 | head -10

doesnt seems properly formatted when i use Content-Type: text/html; charset=ISO-8859-1.

--- Updated Post - Automerged ---

linuxtechie said:
Try this : txt2html - Text to HTML converter

Or anyother that suits your cup of coffee.

+LT

Will this need any package installation in the server?

If yes then strict no (Thanks to strict policies implemented)
 
The output you wanted is not even in html its just a plain , you want them in tabular format ?

You can send some parts in text and others in html but you need you Content type for it

Example -

Code:
cat FILENAME <<HERE |mailx 

From: ${MAILFROM}

To: ${MAILTO}

Subject: Same subject

Content-Type: text/html; charset=us-ascii

Content-Transfer-Encoding: 7bit

MIME-Version: 1.0

HERE
 
Back
Top