linuser2 has asked for the wisdom of the Perl Monks concerning the following question:

Hello. How would I go about attaching a file to an e-mail? I've got a filehandle open to sendmail ("|/path/to/sendmail") and can send regular e-mail. How would I attach a file? I presume some uuencoding or MiME ?.... modules? Thanks in advance....

Replies are listed 'Best First'.
Re: Mail attachments
by btrott (Parson) on Mar 24, 2000 at 00:53 UTC
    Take a look at MIME::Lite.

    From the Docs:

    # Create a new single-part message, to send a GIF file: $msg = new MIME::Lite From =>'me@myhost.com', To =>'you@yourhost.com', Cc =>'some@other.com, some@more.com', Subject =>'Helloooooo, nurse!', Type =>'image/gif', Encoding =>'base64', Path =>'hellonurse.gif'; # Send in the "best" way # (the default is to use "sendmail"): $msg->send;
RE: Mail attachments
by zak (Initiate) on Mar 28, 2000 at 09:01 UTC
    It is also fairly easy to do it the manual way with MIME::Base64 and reading of the MIME rfcs (I forget what they are ;-). Also look at mpack command line utility. HTH
      Hi, I use munpack and Perl (of course) to parse mail attachments containing positional formatted interface files and have run into problems with "format=flowed" encoded files. I'm using mpack 1.5 and can't seem to find a newer version capable of dealing with this fairly new format. Just wondering if any of you have run into this problem and might have a work around? Many thanks in advance.