Emailing html file as body not attachment


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Emailing html file as body not attachment
# 1  
Old 06-08-2011
Question Emailing html file as body not attachment

Hi All,

I want to send the html file as message body not as an attachment. below is my code.it is printing the html code as it is in the email.
your help is needed urgently.
Code:
 
VTIER=$ROOTHOME/vtierlist2.txt
genhtml=/$ROOTHOME/genhtml.html
MAILTO=/$ROOTHOME/maillist
SUBJECT="Vtier Usage Report"
i=0
j=0
cat /dev/null > $ROOTHOME/genhtml.html
#################array of servers/usage######################
for server in `cat $VTIER`;
do
vtier[$i]=$server
usage[$i]=`sshcmd -u ${vtier[$i]} -s ${vtier[$i]} " df -k ." |  awk '{ print $5 " " $6 }' | cut -d " " -f1|tail -1`
echo server=${vtier[$i]} and usage = ${usage[$i]}
i=$i+1
done
##############print the server and usage######################
echo "Content-Type: text/html">>$genhtml
echo "<html>" >>$genhtml
echo "<body>" >>$genhtml
echo "<table border=\"1\">" >>$genhtml
echo "<tr>" >>$genhtml
echo "<td><b> Server </b></td>" >>$genhtml
echo "<td><b> Usage </b></td>" >>$genhtml
echo "</tr>" >>$genhtml
while [ $j -le $i ]
do
echo " <tr>" >>$genhtml
echo  " <td> ${vtier[$j]}</td>" >>$genhtml
echo " <td>  ${usage[$j]} </td>"  >>$genhtml
echo "</tr>" >>$genhtml
j=$j+1
done
echo "</table>" >>$genhtml
echo "</body>" >>$genhtml
echo "</html>" >>$genhtml
cat $genhtml | /usr/ucb/Mail -s "$SUBJECT" `cat $MAILTO`
#uuencode ${genhtml} ${genhtml}|mailx -s "$SUBJECT" `cat $MAILTO`

# 2  
Old 06-08-2011
Add this on top of your html file

Code:
 
To: To mail id
From: From mail id
Subject: Sub 
MIME-Version: 1.0
Content-Type: text/html

send the mail using following command

Code:
 
cat htmlfile | /usr/lib/sendmail -t

# 3  
Old 06-08-2011
replace
Code:
cat $genhtml | /usr/ucb/Mail -s "$SUBJECT" `cat $MAILTO`

to
 
cat $genhtml | /usr/sbin/sendmail address@example.com

sendmail supports html

Send HTML formatted mail from Unix using Sendmail - Tech-Recipes
# 4  
Old 06-08-2011
thanks a lot Kamraj...it solved my problem..
one more question - the mail is send as host name as the sender..I want my email address in sender list..is there any option for that in sendmail..
# 5  
Old 06-08-2011
Quote:
Originally Posted by amitbisht9
thanks a lot Kamraj...it solved my problem..
one more question - the mail is send as host name as the sender..I want my email address in sender list..is there any option for that in sendmail..
Add this on top of your file

Code:
 
From: aa@mail.com

# 6  
Old 06-08-2011
try this..

Code:
(
echo "From: you@your_company.com"
echo "To: you@your_company.com"
echo "MIME-Version: 1.0"
echo "Subject: Test Message"
echo ""
echo "This is a MIME-encapsulated message"
echo ""
echo "Content-Type: text/html"
echo ""
cat $genhtml
) | sendmail -t

# 7  
Old 06-08-2011
Data

Thanks..

I tried the above code but it is not working..and printing the from:,to:,MIME type (in echo command) as it is in the output.Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Need syntax for mailing in UNIX by using html file as body and along with attachment

Hi All, I need a syntax for mailing in unix by using html code file output as body and along with attachment (without using mutt command) HTML code file : html1.txt Attachment : attach1.txt I was using the below codes but they are not working. ( cat html1.txt ; uuencode attach1.txt... (4 Replies)
Discussion started by: Rokkesh
4 Replies

2. Shell Programming and Scripting

Sendmail cmd for html body and attachment not working

Hi, I am having trouble in sending a mail with html body and attachment (csv file). We don't have uuencode or mutt (not allowed to install as well) The below code is perfectly working for sending the html body alone: export MAILTO=abc@xyz.com export CONTENT="/home/abc/list.html"... (2 Replies)
Discussion started by: close2jay
2 Replies

3. UNIX for Dummies Questions & Answers

Sendmail with HTML body and attachment code issues

Hi, I was working on getting an HTML file in the mail body along with attaching a "csv" file to the mail. Below are the 2 parts of the code. I need help with the second part where I'm sending the mail. The HTML file as an attachment is perfect without any issues and with proper formatting.... (6 Replies)
Discussion started by: aster007
6 Replies

4. Shell Programming and Scripting

Issue to attachment with HTML body

HI Team, I used below code to get attachment with HTML body. i having21062013.csv file . but i am getting junk .csv file. Can you please help me out. export MAILTO=rp908@gmail.com.com export SUBJECT="Test Waiver Code email" export BODY=test.html export ATTACH=21062013.csv... (4 Replies)
Discussion started by: Jewel
4 Replies

5. Shell Programming and Scripting

Sendmail with HTML body and attachment

I have an HTML file I am currently sending in the body of an email. I now have a need to send a csv attachment along with it. I can ONLY use sendmail as mutt and xmail etc are not on the server. Here is what I am currently using: It is possible to add code to add an attachment ??!? { ... (8 Replies)
Discussion started by: atelford
8 Replies

6. Red Hat

Send HTML body and HTML attachment using MUTT command

Hi there.. I need a proper "mutt" command to send a mail with html body and html attachment at a time. Also if possible let me know the other commands to do this task. Please help me.. (2 Replies)
Discussion started by: vickramshetty
2 Replies

7. Shell Programming and Scripting

Sendmail with html attachment and html body

Hi folks, I have a perl script which sends out email after successful completion of job as inline html, I want to send it out as two parts now as html inline and html attachment. see the attached script. Thanks in advance (1 Reply)
Discussion started by: sol_nov
1 Replies

8. Shell Programming and Scripting

emailing as body of email

hi all, how do i email a file in the body of an email rather than as an attachment ?? have a ksh script which i need to read a file and email as part of the body rather than an attachment. my code is : uuencode file.log | mailx -s "test" but this sends file as an attachment. ... (2 Replies)
Discussion started by: cesarNZ
2 Replies

9. AIX

Command line/Script to send E-mail with HTML body and binary attachment

I apoligize for the cross-post but I'm not getting much in the way of help in the dummies forum: I'm trying to script sending an e-mail message on an AIX 5.x server with the following requirements: 1. command line switch to specify file name containing message body in HTML format 2. command... (3 Replies)
Discussion started by: G-Man
3 Replies

10. UNIX for Dummies Questions & Answers

AIX send mail with HTML message body and a binary attachment

I'm trying to script sending an e-mail message on an AIX 5.x server with the following requirements: 1. command line switch to specify file name containing message body in HTML format 2. command line switch to specify file name of a binary attachment 3. command line or input file to specify... (4 Replies)
Discussion started by: G-Man
4 Replies
Login or Register to Ask a Question