I first came across MIME::Lite about 2 years ago when working on an online mail system. We had some in house code that we had been using to create outgoing messages, but it was ugly and brittle.
MIME::Lite in a Nutshell
### Create a new multipart message:
$msg = MIME::Lite->new(
Cc =>'email@example.com, firstname.lastname@example.org',
Subject =>'A message with 2 parts...',
### Add parts (each "attach" has same arguments as "new"):
Data =>"Here's the GIF file you wanted"
Disposition => 'attachment'
Output a message:
### Format as a string:
$str = $msg->as_string;
### Print to a filehandle (say, a "sendmail" stream):
Send a message:
### Send in the "best" way (the default is to use "sendmail"):
MIME::Lite supports several methods to send the message via SMTP.
If you need to create a valid email with attachments then MIME::Lite is one of the easiest most mature modules I have found. Easy because you don't need to know much about RFC822 to use it. The public interface that it offers is well thought out and provides access to almost every aspect of the class. That is also why I feel it is a very mature module. As of this write up it is on version 2.117. The author of this module is also the author of MIME-tools. The interface for MIME::Lite is much easier for the end user then that of MIME-tools in my opinion. MIME-tools have a steep learning curve if you are new to Perl. Regardless the authors understanding of the MIME proctocol is much more indepth then most people will need and MIME::Lite provides a simpe way to build outgoing mail messages.
Are you posting in the right place? Check out Where do I post X? to know for sure.
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
Want more info? How to link or
or How to display code and escape characters
are good places to start.