You can use Mail::Sender for sending emails with attachments.
I've just put simple example from my project for sending PDF file as attachment.
See also Mail::Sender documentation for more details and examples.

my $body = 'This is a body of your message!'; # Define a hash with mail data my $data_href = { to => 'recipients mails', body => \$body, + ctype => 'text/plain', smtp => 'your smtp server', from => 'your email addr', replyto => 'reply to addr', + subject => 'Your subject', }; my $sender = new Mail::Sender() or die "Cannot create sender objec +t!"; $sender->OpenMultipart( { %$data_href, encoding => "quoted-printable", debug => '/your/place/for/log fil +e', } ); warn "Error in mailing : $Mail::Sender::Error\n" unless ref $sende +r; $sender->Body( { msg => ${$data_href->{body}}, ctype => $data_href->{ctype}, encoding=> 'Base64', } ); $sender->Attach( { file => 'your attach file', description => 'Your attach description', ctype => 'your attach file mime type', encoding => 'Base64', disposition => "attachment; file='your attach + file'; type='PDF'", } ); $sender->Close; if(defined $sender->{error}) { warn "Error of sending mail to '$$data_href{to}': ".$sender-> +{error}."!!!" } else { warn "Mail was sent to the '$$data_href{to}'!" }

Also, there is another way for building email messages - use MIME::Entity. It's a part of MIME::tools library. Actually, I don't use this module, but I've seen it in some application and heard that it's a good solution.

Hope I helped.

      
--------------------------------
SV* sv_bless(SV* sv, HV* stash);

In reply to Re: Piping Email to Perl with attachments by nite_man
in thread Piping Email to Perl with attachments by Anonymous Monk

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.