HTML not coming while sending using email


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting HTML not coming while sending using email
# 1  
Old 01-23-2017
HTML not coming while sending using email

Code:
echo "$1" > test.txt
awk 'BEGIN{
FS="|"
print  "MIME-Version: 1.0"
print  "Content-Type: text/html"
print  "Content-Disposition: inline"
print  "<HTML>""<TABLE border="1"><TH>Heading1</TH><TH>Heading2</TH><TH>Heading3</TH>"
}
 {
printf "<TR>"
for(i=1;i<=NF;i++)
printf "<TD>%s</TD>", $i
print "</TR>"
 }
END{
print "</TABLE></BODY></HTML>"
 }
' test.txt > test.html

cat test.html | mailx -s "TEST" aaa@abc.com

file content:
Code:
abc|ccccc|dddd

end html file:
Code:
MIME-Version: 1.0
Content-Type: text/html
Content-Disposition: inline
<HTML><TABLE border=1><TH>Heading1</TH><TH>Heading2</TH><TH>Heading3</TH>
<TR><TD>AAA</TD><TD>AAAAAA</TD><TD>AAAA</TD></TR>
</TABLE></BODY></HTML>

I am getting email but the its just writing the same end html file into the body instead of creating a table.


Moderator's Comments:
Mod Comment Please use CODE tags as required by forum rules!

Last edited by RudiC; 01-23-2017 at 04:21 PM.. Reason: Added CODE tags.
# 2  
Old 01-24-2017
Try using sendmail instead:-
Code:
awk -F\| '
        BEGIN {
                print "To: abc@abc.com"
                print "Subject: TEST"
                print "MIME-Version: 1.0"
                print "Content-Type: text/html"
                print "Content-Disposition: inline"
                print "<HTML>"
                print "<BODY>"
                print "<TABLE border=1>"
                print "<TH>Heading1</TH><TH>Heading2</TH><TH>Heading3</TH>"
        }
        {
                print "<TR>"
                for( i = 1; i <= NF; i++ )
                        print "<TD>" $i "</TD>"
                print "</TR>"
        }
        END {
                print "</TABLE>"
                print "</BODY>"
                print "</HTML>"
        }
' test.txt | /usr/sbin/sendmail -t

# 3  
Old 01-27-2017
I think you need a blank line after Content-Type
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Need help in sending html mail with attachment

Hi Everyone, I am facing problems in sending html mail with attachemnt. I will able to send mail with attachment (plain text ) using mailx -s and uuencode command and also html mail without attachment using sendmail option. However I am not able to send html mail along with attachment.Either... (2 Replies)
Discussion started by: karthik adiga
2 Replies

2. Shell Programming and Scripting

Sending HTML Email

1) Can you please provide me with a best example of how to send an HTML email via mutt or mail or send email commands using bash shell. 2) I tried below but i am not able to get the variable values in the HTML email output. (cat <<-EOT <html> <head><title></title> </head> <body> <p>Hello,... (9 Replies)
Discussion started by: Ariean
9 Replies

3. Shell Programming and Scripting

[Solved] Sending a HTML email from cli loses formatting.

Hi, I have a .sh file, to email a report of our backups from a linux machine. It looks like this (minus a few bits): echo "HELO $host.$domain" sleep 1 echo "mail from: vdrreport@$domain" sleep 1 echo "rcpt to:$mailto" sleep 1 echo "data" sleep 1 echo "subject: $host VDR-Report... (2 Replies)
Discussion started by: cognito
2 Replies

4. Shell Programming and Scripting

Sending a csv attachment and html text together.

Hello, I need to send below text (in a file ABC)as html text in mail body and the same as csv attachment 1,2,3 4,5,6 7,8,9 but to send as html text in mailbody we use echo "Subject: Report " | cat - ABC | /usr/lib/sendmail -t a@xyz.com and to send as an attachment in csv format we... (9 Replies)
Discussion started by: skhichi
9 Replies

5. Shell Programming and Scripting

Weird ? symbol coming through-sending text file

Hi All, When I am trying to send a text file through Unix,I get a weird symbol in the .txt file. The symbol is ? in a box (square)....which is making the file unloadable. Please help me with the solution. Thanks in advance Gopi (1 Reply)
Discussion started by: gopi.palleti
1 Replies

6. UNIX for Dummies Questions & Answers

Sending html email with html attachment

Hello, I have a script which is sending an html file as an attachment. #!/usr/bin/ksh export MAILTO="user@company.com" export CONTENT="/usr/tmp/file.html" export SUBJECT="EmailSubject" ( echo "Subject: $SUBJECT" echo "MIME-Version: 1.0" echo "Content-Type: text/html" echo... (0 Replies)
Discussion started by: sreenathkg
0 Replies

7. Shell Programming and Scripting

Using top command to email if process is exceeding 25% and sending an email alert if so

This is my first time writing a script and Im having some trouble, Im trying to use the top command to monitor processes and the amount of CPU usage they require, my aim is to get an email if a process takes over a certain percentage of CPU usage I tried grep Obviosly that hasnt worked, Any... (8 Replies)
Discussion started by: jay02
8 Replies

8. Shell Programming and Scripting

Sending HTML Email through mailx

Hi, I am trying to send html email using mailx like follow on sh shell (Bourne) on HP-UX: mailx -s "Test HTML output in outlook MIME-Version: 1.0 Content-Type: text/html" receiver@host.com < file.txt Content of file.txt are as follows: <html> <h2>An important link to look at!</h2>... (3 Replies)
Discussion started by: manubatham20
3 Replies

9. Shell Programming and Scripting

Sending HTML attachment through mail

Hi I am new to unix and scripting.I am trying to send a html file as an attachment. SUBJECT="Type of Exceptions in Application" TO=Sushovan.Samals@gmail.com SPOOLFILE=/data/reg/tlogs/Monitor.html #echo "Send the E-mail message..." uuencode $SPOOLFILE $SPOOLFILE | mailx -s "$SUBJECT" $TO... (2 Replies)
Discussion started by: sushovan
2 Replies

10. UNIX for Dummies Questions & Answers

sending mail with html content

hi, I am new to unix. I need send html content as a mail from my sun-solaris2.6 work station. When I tried that the recipient gets it as html code with all the tags. any solutions? thanx in advance (2 Replies)
Discussion started by: gmchoudary
2 Replies
Login or Register to Ask a Question