in reply to Another MIME::Lite/Net::SMTP Question

I looked through countless nodes yesterday for a truly working example of how to send attachments using MIME::Lite. Unfortunately, most people seemed content to post untried code. So after some aggravation, cursing, head-scratching, and whatever else, here is something that actually works because I just finished running it. Enjoy:
use strict; use lib '/lnc/brannon/scripts/perl/lib/perl5/site_perl/5.6.0'; use MIME::Lite; my $msg = MIME::Lite->new ( From =>'brannon@lnc.usc.edu', To =>'princepawn@yahoo.com', Subject =>'A message with 2 parts...', Type =>'multipart/mixed' ); ### Add parts (each "attach" has same arguments as "new"): $msg->attach ( Type =>'TEXT', Data =>"Here's the JPEG file you wanted" ); $msg->attach ( Type =>'image/jpeg', Path =>'/lnc/brannon/public_html/pix/me/36.jpg', ); $msg->send('smtp','lnc.usc.edu');

Replies are listed 'Best First'.
RE: A living,breathing, fully-working MIME::Lite example
by lachoy (Parson) on Nov 03, 2000 at 19:36 UTC

    I'm not sure you looked hard enough. Check out RE: sending email. This script is used every day from a cron job and it's been tested under Linux and NT, which basically passes for cross-platform these days :)

RE: A living,breathing, fully-working MIME::Lite example
by agoth (Chaplain) on Nov 03, 2000 at 23:30 UTC