how to create embedded html email

Posted on 2014-08-20
Last Modified: 2014-08-27
I'd like to create an email with html formatting via a batch process in Linux using mailx. I can easily create an html doc using the right tags, but if I just send that as the message body I get an email showing the raw html.

How to I make it show the rendered html?
Question by:jmarkfoley
    LVL 18

    Assisted Solution

    by:Andrej Pirman
    You need to properly format message as HTML, not just send HTML instead of mail body.
    Try this converter (free) and you might see the propeer encoding:

    Are you using Linux shell to batch convert?
    LVL 82

    Assisted Solution

    by:Dave Baldwin
    This page shows how to use PHP to create a complete email with both text and HTML sections that uses the proper headers to identify each part.  Also includes attachments.  Without the Content-Type headers, HTML is not recognized.
    Content-Type: text/html; charset="iso-8859-1"
    Content-Transfer-Encoding: 7bit

    Open in new window

    LVL 1

    Accepted Solution

    OK, I found 2 solutions:
    $ senmail -t <<EOF
    Date: Thu, 21 Aug 2014 01:14:29 -0400
    Subject: test html
    Content-Type: text/html

    Open in new window

    ... of course there are lots of way to pipe into sendmail.

    Solution 2:
    mutt  -e 'set content_type="text/html"' -s "test html" <my.html

    Open in new window

    I like the 2nd method because I don't have to specify the time (having no Time: header tends to generate spam points in spamassassin) and I don't have to specify my sender email address. Basically, it works just like mailx except that I have a -e option in mutt to set the content type whereas (after exhaustive searching of the man page) there is no such option in mailx. Also, method 2 lets me create a standalone html file with no mail headers prepended.

    Andrej Pirman: Your site looked interesting, but requires one to register first -- which I'm disinclined to do -- and also says the site does not work with IE, and I didn't really feel like firing up firefox in addition to registering. Besides, all I needed is one header, which Dave Baldwin listed, but really needed to know *how* to get that into my mail client.

    Other comments before closing?
    LVL 1

    Author Closing Comment

    I found the solution I needed.

    Featured Post

    Top 6 Sources for Identifying Threat Actor TTPs

    Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

    Join & Write a Comment

    Are you having trouble connecting or getting your iPhone / Samsung device(s) to sync with Microsoft Exchange Server?   What have you tried?   What haven't you tried?
    Email signatures have numerous marketing benefits. Here are 8 top reasons to turn your email signature into a marketing channel.
    Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
    Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

    731 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now