Sending zip file as attachments in perl

Hi All,

i have a code, where that script is sending mail to the users, but i want to enhance
it, i.e i need to add attachment(zip file) to that, i dont want to use MIME:LITE module or any other module, with this simple code, i need to enhance.

below is my code

my %mail_params = (HTML    => $mail_body,
                       Text    => $mail_body,
                       From    => $MAIL_FROM,
                       To      => $MAIL_TO,
                       Subject => $mail_subject,);

    $mail_params{HTML} = "<HTML><pre>$mail_params{Text}<\><\\HTML>";
    my $mail = HTML::Mail->new(%mail_params);

$mail->send()

I dont want to use any modules, like MIME, sendmailer .....

Thanks,
ASAK

Hi ,

Anyone who can post some solution for this ????

Thanks,
asak

---------- Post updated at 06:36 AM ---------- Previous update was at 06:31 AM ----------

HI,

Any solution, using simple mail in perl with attachment, please let me know.

Thanks,
Asak

Hi,

Why don't you want to use any module?

Regards,
Birei

Hi Birei,

i want to share this script which mails with attachments to end-users. where they done know about installations and modules, just they'll execute the script. that's y i dont want to install any module in customer system, simple mail with zip file attachment i need.

Thanks,
Arun

Hi All,

I came to know that i can use mutt command, to send mails with attachments, in shell i can send, and when i execute

`mutt -a <file_name> ak@apps.com < /dev/null`

in command line, i received mail with attachment, so i used this command in perl script using back quotes ` . i'm not able to execute properly. i'm getting an error as when i used mutt in perl script.

Error sending message, child exited 67 (User unknown.).

Can anyone let me know how to send attachment in perl without using any modules,

Thanks,
asak

can u just try system command instead of using ` back quotes.

HI Latika,

i tried using system command with ` quotes. i got same error.

Error sending message, child exited 67 (User unknown.).

Below is my standalone script to send file(filer.txt)

$LOGDIR="/home/user3/filer.txt";

$email = "asak@gmail.com";
#$a = `sudo echo | mutt -a $LOGDIR arunak@netapp.com < /dev/null`;
system (`mutt -a $LOGDIR asak@gmail.com < /dev/null`);
#system ("sh mutt -a $LOGDIR asak@gmail.com < /dev/null");
#my $cmd = "echo mutt -a $LOGDIR asak@gmail.com < /dev/null";
#my $check_ps = `$cmd`;

is there are any other way to send mail with attachments, without installing modules.

Thanks,
Asak

don't put ` back quotes inside the system function,
just try below line,

system ("mutt -a $LOGDIR asak@gmail.com < /dev/null");

---------- Post updated at 12:23 AM ---------- Previous update was at 12:16 AM ----------

Hi Asak,

dont put ` back quotes inside the system function,
just use below line,

 system("mutt -a $LOGDIR asak@gmail.com < /dev/null"); 
 
system(qq(mutt -a $LOGDIR asak@gmail.com < /dev/null));

Hi latika & itkamaraj

i tried using system, same error i'm getting

Error sending message, child exited 67 (User unknown.).
Could not send the message.

i think, mutt cannot be run from script, in command line it works fine, any solution other than this. it'll be very helpful...

Thanks,
Asak

Try this...

system(qq(mutt -a $LOGDIR asak@gmail.com) < /dev/null);

HI itkamaraj,

i tried both the ways, this

system(qq(mutt -a $LOGDIR asak@gmail.com) < /dev/null); 

will results in syntax error

Bareword found where operator expected at att.pl line 2, near "/dev/null"
        (Missing operator before null?)
syntax error at att.pl line 2, near "/dev/null"
Execution of att.pl aborted due to compilation errors.

and executing

system(qq(mutt -a $LOGDIR asak@gmail.com < /dev/null));

will results in same error :

Error sending message, child exited 67 (User unknown.).
Could not send the message.

Any other ways??? ?

regards,
Asak

open( MUTT , "mutt -a $LOGDIR asak@gmail.com) < /dev/null |" );
close( MUTT );

or you can use exec() method

can u try the uuencode command to send a attachment.

system("uuencode file.zip file.zip | mailx -s subject emailid");

in uuencode command, filename needs to place two times.
i think this ll solve ur problem