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

how can I send a mail with attachment using send-mail module? I am using the code below

my %mail = ( To => $to, From => $from, File => '/var/www/ef-cok/cgi-bin/jomon.txt', subject=> $subject, ); $mail{Smtp} =$smtp; sendmail %mail

The mail is sending but the attachment is not attached. please help me...

Replies are listed 'Best First'.
Re: sending mail with attachment using send mail
by Corion (Patriarch) on May 18, 2010 at 10:48 UTC
Re: sending mail with attachment using send mail
by leslie (Pilgrim) on May 18, 2010 at 11:16 UTC

    You can use this code.

    use strict; use warnings; use lib '/home/technical/Perl/module/share/perl/5.8.8'; use MIME::Lite; my($msg,$filename); $filename="./mimelite.pl"; $msg =MIME::Lite->new( #From =>'bks@gmail.com', To => 'dhadha@gmail.com', #To => 'leslie.bks@gmail.com', Subject => 'Testing with mime::lite module this is used to send ma +ils to others', Data => 'I have sent this mail using my perl script. Please check +the attachment which has that script.' ); $msg->attach( Type =>'TEXT', Path => $filename, Disposition => 'attachment' ); $msg->send();