On Tue, Dec 05, 2000 at 02:47:39PM +1100, Colin Humphreys wrote:

> I have a progect that involves being able to send mail to a smtp server.
> This now requires to be able to send attachments. 
> 
> Is there a little app around that will mime-encode a binary and dump
> back the encoded stuff....?

Try the perl module Mail::Sender:

   http://search.cpan.org/search?dist=Mail-Sender
   
You use it like this for a single file:

    $sender = new Mail::Sender({from => "${from}",
                                to => "${to}",
                                subject => "${subject}",
                                smtp => "${smtp_server}"});
    $sender->MailFile({file => "${file}",
                       msg => "${msg}\r\n\r\n",
                       ctype => 'text/plain',
                       encoding => 'quoted-printable'});


or for multiple files:

    $sender = new Mail::Sender({from => "${from}",
                                to => "${to}",
                                subject => "${subject}",
                                smtp => "${smtp_server}"});

    $sender->OpenMultipart({boundary => "${boundary}",
                            type => 'multipart/mixed'});
    $sender->Body();
    $sender->Send("${msg}\r\n\r\n");
    foreach $file (@files))
    {
        $sender->SendFile({file => "${file}",
                           ctype => 'text/plain',
                           encoding => 'quoted-printable'});
    }
    $sender->Close();


Note the "\r\n" line terminators in the message body.  The multipart
boundary can be any text you like, just make sure it's something that
doesn't appear in the message body or in any of the attached files. 
Adjust the content type and encoding to match what you're sending.  If
it's an image, you can specify Dispostion: inline to have it appear as
an inline image (rather than as an attachment) in those mail clients
which support such things (e.g. Netscape).


Cheers,

John
-- 
whois [EMAIL PROTECTED]


-- 
SLUG - Sydney Linux User Group Mailing List - http://slug.org.au/
More Info: http://slug.org.au/lists/listinfo/slug

Reply via email to