Find the answer to your Linux question:
Results 1 to 9 of 9
hi! i woult like to make a report, and send to my mail in html format. I have this: Code: #!/bin/bash echo "<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">" ...
  1. #1
    Just Joined!
    Join Date
    Oct 2008
    Posts
    48

    send a report in html format

    hi! i woult like to make a report, and send to my mail in html format.
    I have this:


    Code:
    #!/bin/bash
    
    echo "<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">"  > /root/file.html
    echo "<html>" >> /root/file.html
    echo "<head>" >> /root/file.html
    echo "<meta content="text/html; charset=utf-8" http-equiv="Content-Type">" >> /root/file.html
    #echo "<title></title>" >> /root/file.html
    echo "<body>" >> /root/file.html
    echo "<FONT FACE="verdana" SIZE="2">" >> /root/file.html
    
    echo "SERVER:" `hostname` >> /root/file.html
    
    echo "</font>" >> /root/file.html
    echo "</body>" >> /root/file.html
    echo "</html>" >> /root/file.html
    
    echo "" | mail -s user_01@gmail.com < /root/file.html
    why my browser don't put the text in the size and font correctly?
    Are any solution for my case?

    thanks!

  2. #2
    Just Joined!
    Join Date
    Nov 2008
    Posts
    11
    Which browser?

    BTW you haven't closed your head element. It *could* be the cause of the problem depending on the html renderer being used.

  3. #3
    Just Joined!
    Join Date
    Oct 2008
    Posts
    48
    for example gmail or Lotus,....

  4. #4
    Just Joined!
    Join Date
    Nov 2008
    Posts
    11
    Lotus Notes is horrible for HTML emails but what you've got should probably work - still fix the head element though.

  5. #5
    Just Joined!
    Join Date
    Nov 2008
    Posts
    11
    More thoughts, when we do marketing emails (often to Lotus Notes as that's what my corporation uses), we tend to have best results using HTML 4 with *inline* styles.

    So you could try
    Code:
    echo "<body>" >> /root/file.html
    echo "<p style="font-family: Verdana; font-size: 11px">" >> /root/file.html
    echo "SERVER:" `hostname` >> /root/file.html
    echo "</p>" >> /root/file.html
    echo "</body>" >> /root/file.html

  6. #6
    Just Joined!
    Join Date
    Oct 2008
    Posts
    48
    If i put:

    Code:
    #!/bin/bash
    
    echo "<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">"  > /export/home/oper/prova.html
    echo "<html>" >> /export/home/oper/prova.html
    echo "<head>" >> /export/home/oper/prova.html
    echo "<meta content="text/html"; charset="utf-8" http-equiv="Content-Type">" >> /export/home/oper/prova.html
    echo "<p style=font-family: Verdana; font-size: 11px>" >> /export/home/oper/prova.html
    
    echo "SERVER:" `hostname` >> /export/home/oper/prova.html
    
    echo "</p>" >> /export/home/oper/prova.html
    echo "</body>" >> /export/home/oper/prova.html
    
    echo "</body>" >> /export/home/oper/prova.html
    echo "</html>" >> /export/home/oper/prova.html
    
    
    echo "" | mail -s user_01@gmail.com < /export/home/oper/prova.html
    the result in gmaill.com:

    <!DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.01 Transitional//EN http://www.w3.org/TR/html4/loose.dtd>
    <html>
    <head>
    <meta content=text/html; charset=utf-8 http-equiv=Content-Type>
    <p style=font-family: Verdana; font-size: 11px>
    SERVER: MYSERVER
    </p>
    </body>
    </body>
    </html>


    but my result should be only:

    SERVER: MYSERVER

  7. #7
    Linux Newbie
    Join Date
    Jul 2008
    Posts
    181

  8. #8
    Just Joined!
    Join Date
    Nov 2008
    Posts
    11
    I don't use shell script but do you need to escape the "s so that they show up?

    E.g. it should read
    style="font-family: Verdana; font-size: 11px"
    meta content="text/html; charset=utf8"
    etc.
    - the quotes are important.

    Also, you still need to close that head tag.
    After outputing the meta element,
    echo "</head>" >> /export/home/oper/prova.html

    But if you're getting the fuill html source displayed like that then chances are the mail is not being sent with the correct content type headers etc.

    The content type in the email header needs to be set to "text/html; charset="utf-8" to match the type listed in the HTML source.

    I don't think you can do that with the mail command. You could try using sendmail instead - Linux, send html email from command line

  9. #9
    Just Joined!
    Join Date
    Oct 2008
    Posts
    48
    thanks for the links!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...