how to send html email from shell script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting how to send html email from shell script
# 1  
Old 10-03-2012
how to send html email from shell script

This is my below script which is working fine as it send only plain text email.

So My question is- How can I modify my below script to send this as an HTML formatted email? I want to show the text color of this expression `(echo "100*$TEST2/$TEST1" | bc -l)` as `RED` in an email and that can be done only in HTML formatted emails. So that is the reason I was thinking to send an email in HTML formatted way. Any suggestions will be of great help.


Code:
 #!/bin/bash
    
    TEN_DAYS="3793274 230667"
    
    TEST1=`echo $TEN_DAYS | awk '{print $1}'`
    echo $TEST1
    
    TEST2=`echo $TEN_DAYS | awk '{print $2}'`
    echo $TEST2
    
    mailx -s "Report" -r uname@host.com uname@host.com <<EOF
    
    Error  Percentage: `(echo "100*$TEST2/$TEST1" | bc -l)`
    
    EOF

# 2  
Old 10-03-2012
Quote:
Originally Posted by raihan26
How can I modify my below script to send this as an HTML formatted email?[/CODE]
Use HTML encoding for this...

try to implement HTML tags in it..

read this
# 3  
Old 10-03-2012
Thanks pamu for the link. I know HTML already but I don't know how to add that in the shell script. Can you please give some suggestion basis on my code then I will be able to understand more. Appreciated your help on this.
# 4  
Old 10-03-2012
try something like this...

Code:
echo "Subject: Subjecy" > File_Out
echo "FROM: From_name" >> File_Out
echo "To: to@to.com" >> File_Out
echo "Content-Type: text/html; charset=us-ascii" >> File_Out
echo >> File_Out
echo "<!doctype html public \"-//w3c//dtd html 4.0 transitional//en\">" >> File_Out
echo "<html>" >> File_Out
echo "<pre>" >> File_Out
echo "<font size=3 color=blue><b>Message Body</b></font>" >> File_Out

/usr/lib/sendmail "to@to.com" < File_Out

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. HP-UX

Unable to send attachment with html tables in UNIX shell script

Heyy, any help would be grateful.... LOOKING FOR THE WAYS TO SEND AN EMAIL WITH ATTACHMENT & HTML TABLES IN BODY THROUGH SHELL SCRIPT (LINUX)..NOT SURE, IF WE HAVE ANY INBUILT HTML TAG OR UNIX COMMAND TO SEND THE ATTACHMENTS. KINDLY HELP below is small script posted for our understanding..... (2 Replies)
Discussion started by: Harsha Vardhan
2 Replies

2. Shell Programming and Scripting

How to send email HTML + PDF attachment?

I am attempting to write a script where I can pass in parameters ( to , from, the location of a pdf attachment ) and send an email that has HTML for the body content and a PDF as an attachment. I have failed to achieve this with sendmail and mutt. I recently found this. If there are any... (2 Replies)
Discussion started by: jvsrvcs
2 Replies

3. Shell Programming and Scripting

Help with shell script to send email once

Hi Guys, I have this script which will monitor oracle db process if up or down.And I want it to send email if it's down and the time it's back to online. However my script just keep on sending "Email Up" if the db is up or "Email Down" if the db is down.Is there any way to trap it so that it... (5 Replies)
Discussion started by: d3xt3r
5 Replies

4. Shell Programming and Scripting

Display both html and plain text in email in shell script

Hi, I want to display both html and plain in email in my script. i tried the below code code: export MAILTO="ssi@a.com" export CONTENT1="$htmlfile" export CONTENT2="$plainfile" export SUBJECT="INFO " export MAILFROM="si@a.com" ( echo "Subject: $SUBJECT" echo "MIME-Version:... (4 Replies)
Discussion started by: sreelu
4 Replies

5. UNIX for Advanced & Expert Users

How to send email as HTML format with attachment ?

hi.. Could somebody help me how to sent an attachment using sendmail command and the content is HTML format ?. Below is my code to sent the email as HTML but i do not know how to sent the attachment, please help me To: "BAHARIN HASAN"<baharin.hasan@gmail.com> from: "DATAONE SDN... (4 Replies)
Discussion started by: bh_hensem
4 Replies

6. Shell Programming and Scripting

Script to send email after comparing the folder permissions to a certain permission & send email

Hello , I am trying to write a unix shell script to compare folder permission to say drwxr-x-wx and then send an email to my id in case the folders don't have the drwxr-x-wx permissions set for them . I have been trying to come up with a script for few days now , pls help me:( (2 Replies)
Discussion started by: nairshar
2 Replies

7. Shell Programming and Scripting

How to send email through shell script

Hi All, I am new to the unix , i have to deliver one script very urgently I have to write a shell script where i have i want to send email to specific email id in this script i want FROM to be parameterized and stored in a variable TO to be parameterized and stored in a variable... (3 Replies)
Discussion started by: nileshbhawsar
3 Replies

8. Shell Programming and Scripting

How to send message in html format using shell script

I want to send email message in html format using unix shell script. I use sendEmail command in my script to send email message. The syntaxt of the sendEmail command is as follows: $sendEmail -f <email> -t <email> -u $subject -s smtpserver:port -o message-file=html I should be able to... (1 Reply)
Discussion started by: baps
1 Replies

9. Shell Programming and Scripting

make un shell script to send email

Hi, Someone Knows how to obtein a chain from a unix file, but not all the line, for exemple, for this file ,obtein only 902111111 and to keep the value, this value will be used to make a mailx. NF=ALL, SUBJ= FROM: SN=CD, SE=TOPCALL, NA=, N=902111111, N=TCLFI TO: SE=FAX, NA=, C1=... (0 Replies)
Discussion started by: peybol
0 Replies

10. Shell Programming and Scripting

shell send html email

I know how to send an email with sendmail in a shell script. I know how to send an email with an attachment in a script. But im trying to send an email and need to set Content-Type to text/html and insert a file as the body and not attachment. Send email with file as attachment: ... (4 Replies)
Discussion started by: Ikon
4 Replies
Login or Register to Ask a Question