Hello Monks, I rig up this script below which works fine, however I'm having trouble sending an attachment with it. I read the documentation provided in CPAN about Mail::Sender; but It is not specific as to which option should it be used with ATTACH. The script sends an attachment but it puts it on the email's body instead of creating an object. Do you know how to send an attachment with Mail::Sender as an object instead of putting the attachment into the email's body?? I appreciate if you could point me into the right direction.
use Mail::Sender; $sender = new Mail::Sender { smtp => 'smtp.server', from => 'email address', on_errors => undef, } or die "Can't create the Mail::Sender object: $Mail::S +ender::Error\n"; $sender->OpenMultipart({ to => 'emailaddress1, emailaddress2', cc => 'emailaddress3', subject => 'Log files.' }) or die "Can't open the message: $sender->{'error_msg'} +\n"; $sender->SendLineEnc("This is todays log files "); $sender->SendLineEnc("\nHI, J"); $sender->Attach( {description => 'Daily log', ctype => 'text/plain; charset="us-ascii"', encoding => '7bit', disposition => 'attachment; filename="textfile.txt"', file => 'textfile.txt' }); $sender->Close() or die "Failed to send the message: $sender->{'error_m +sg'}\n"; if ($@) { print "Error sending the email: $@\n"; } else { print "The mail was sent.\n"; }

In reply to Attachment displays in email's body using Mail::Sender 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.