I use Mail::Sender pretty extensively.
Here's a code snippet to get you started for sending an
email with an attachment.
(We let the user's
email client determine the helper application to execute
based on the file extension of the filename we attach to
the message.)
Mail::Sender lets you customize the MIME stuff,
but for simple single files you don't need to do that.
sub send_email
{
my $sender = new Mail::Sender({
from => $from_address,
});
$sender->OpenMultipart({
to => $to_email,
subject => $subject,
});
$sender->Body;
$sender->SendLine( $msg_body );
$sender->SendFile({
description => 'Raw Data File',
encoding => '7BIT',
file => $tempfile,
});
$sender->Close;
}
I really like this module. You should seriously consider
installing it if you find that you are doing a lot with emailing
attachments. It has saved me tons of time.
-
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>
<u> <ul>
-
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
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|