OK - you need to learn about MIME messages before attempting this.

MIME is the standard that allows you to send emails including attachments across the internet. Whenever you send an email message including an attachment, what you're actually sending is a MIME message, that includes two (or more) parts - one containing your message, the other containing the attachment.

MIME also allows you to send "multipart/alternative" messages - which basically means that you can send a message in both HTML and plain text (and also PDF / Word / Whatever) format, and the recipient's mail client will decide which version to display to the user according to its capabilities, and the user's preferences. This is what you actually want to do in this case.

The MIME::Lite module is one of a number on the CPAN that can help you do what you want. I'd suggest reading through the docs for this module, and googling for "MIME" to get an understanding as well.


In reply to Re: email for both plain text and html by dtr
in thread email for both plain text and html by bobdole

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.