in reply to Attach a file to email

MIME::Lite makes this very easy:
use MIME::Lite; my $msg = MIME::Lite->new ( From => 'you@somewhere.com', To => 'someone@somewhere.com', Subject => 'A subject line', Type => 'multipart/mixed'); $msg->attach( Type => 'TEXT', Data => 'Normal text of the email' ); # open a file to send open FILE "file.zip"; my $data = <FILE>; close FILE; $msg->attach( Type => 'BINARY', # or any MIME type you like Data => '$data', Filename => 'file.zip' ); $msg->send;
This link to CPAN will give you lots more info, too.

Replies are listed 'Best First'.
Re: Re: Attach a file to email
by rtoma (Initiate) on Nov 14, 2001 at 06:45 UTC
    Ok. But there's a little problem here. Try to send to an HTML account. I can't. I have tried hard with many smtp servers but nothing. Why?? I can't send it by hand (telnet), too!!! The server accepts the mail but I never receive it. The script hangs and stays when you try to send to a hotmail account... Isn't it couriuos???!!!!