use MIME::Lite; my $from_address = 'me@home.com'; my $out_server = 'out.home.com'; my $subject = "subject"; my $body = <<"MAIL"; blabla MAIL my $document = 'some data' #open and put data into this my $filename = 'see above' ### Create a new multipart message: my $msg = MIME::Lite->new( From => $from_address, To => $email_address, Subject => $subject, Type => 'multipart/mixed' ); ### Add parts (each "attach" has same arguments as "new"): $msg->attach( Type => 'TEXT', Data => $body ); $msg->attach( Type => $mime_type, Data => $document, Filename => $file, Disposition => 'attachment' ); ### use Net:SMTP to do the sending. Depends on your system what to use. eval {$msg->send('smtp', $out_server);}; # via a outbound mailserver eval {$msg->send();}; # sending via local send command on linux system