Sending Attached files from Perl program

I am trying to send an attached file from my perl program.  The e-mail must also have text content in the body of the email as well.  please advise.  Thanks.  
mul9933Asked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
ventolinConnect With a Mentor Commented:
use MIME::Lite;
       

    Create a multipart message (i.e., one with attachments):

        # Create a new multipart message:
        $msg = new MIME::Lite
                    From    =>'me@myhost.com',
                    To      =>'you@yourhost.com',
                    Cc      =>'some@other.com, some@more.com',
                    Subject =>'A message with 2 parts...',
                    Type    =>'multipart/mixed';
       
        # Add parts (each "attach" has same arguments as "new"):
        attach $msg
                    Type     =>'TEXT',  
                    Data     =>"Here's the GIF file you wanted";  
        attach $msg
                    Type     =>'image/gif',
                    Path     =>'aaa000123.gif',
                    Filename =>'logo.gif';

    Output a message:

        # Format as a string:
        $str = $msg->as_string;
       
        # Print to a filehandle (say, a "sendmail" stream):
        $msg->print(\*SENDMAIL);

    Send a message:

        # Send in the "best" way (the default is to use "sendmail"):
        $msg->send;

0
 
mul9933Author Commented:
Do I have to install MIME::lite on my UNIX web server?  If so, where do I get it and how do I install it.
0
 
ventolinCommented:
yes

http://cpan.valueclick.com/modules/by-category/15_World_Wide_Web_HTML_HTTP_CGI/MIME/

or link from www.perl.com

or

perl -MCPAN -eshell

then follow the instructions to setup the shell. when done, type

install Mime::Lite

0
All Courses

From novice to tech pro — start learning today.