---------- Forwarded message ---------- From: Armin Garcia <[EMAIL PROTECTED]> Date: Tue, Jun 17, 2008 at 12:44 PM Subject: Re: How attach files and send mails on perl???? To: [EMAIL PROTECTED]
hi well i have some problems again, thats my new code: #!/usr/bin/perl -w #Modulos use MIME::Lite; use warnings; use strict; ################################################################################## ################ Configuration ################################## ################################################################################## #Ruta del directorio donde se encuentran los attach del email $attach_path="/home/agarcia/HoneyClient/To\-Email"; #log path $log_path="/home/agarcia/HoneyClient/To\-Email/log"; #ruta donde se localiza el script para parsear las bitacoras de CaptureHPC $hpc_log_home="/usr/local/Honeyclient/HoneyClient3/ScriptHoney/capture-server-2.1.0-300"; ################################################################################## ################ Funciones ################################## ################################################################################## sub SendEmailwAttach{ print "Estoy aqui .... tratando de enviar el mail\n"; my $attache= shift(@_); print "attache=$attache"; $msg=new MIME::Lite; $msg = MIME::Lite->new( From => '[EMAIL PROTECTED]', To => '[EMAIL PROTECTED]', # Cc => '[EMAIL PROTECTED]', Subject => 'Reporte de Urls Maliciosas...', Type => 'multipart/mixed' ); @data=`./hpc-log-parser.sh $log_path`; print @data; ### Aqui coloca el texto que deseas !!!!: ### (Note that "attach" has same arguments as "new"): $msg->attach( Type =>'TEXT', Data => "@data" ); ### Aqui agrega el archivo que quieres: $msg->attach( * Type => 'x-gzip', Path => "gzip < $attache |", <------------- i think here is the problem but i dont know why* ReadNow => 1, Filename => 'backup.tgz', Disposition => 'attachment' ) or die "ERROR: here in the attach ...$!"; print "Listoooooo ....\n"; } sub Main{ my $aux; @tmp=`ls $attach_path`; foreach (@tmp){ if ($_ =~ /backup*/){ $aux=$_; } } $file="$attach_path/$aux"; print "archivo=$file"; if ( $file ){ print "Enviando Email w attach\n"; SendEmailwAttach($file); }else{ print "sorry, es un directorio, $aux\n"; } } Main(); Well the problem is i recibe the next output on my terminal when i execute this script *Unsuccessful stat on filename containing newline at /usr/local/share/perl/5.8.8/MIME/Lite.pm line 1549. I dont understand what does mean ... :s when first, only i cant attach files using a variable, this is my problem, if i put a file with the correct name and path, no problem, but my problem is in this directory this file changes with the time I hope somebody helps me, and if you have some tips, all of them are welcome !!! * thanks