hi !!! thanks for your help ....
And im sorry Rob, but this code its not mine ... but thanks, i never see in my mind how you minimize that code, really thanks for your help, and i found another module named MIME::Lite, its more easy to use, and attach files, and do another things very quickly and easy .... But Thank so much I include the code that i'm writting in this time (i mean the time when i was post this message and found this module, and read your replys), i hope my code are more visible :D #!/usr/bin/perl use MIME::Lite; $msg = new MIME::Lite; $msg->build( Type => 'x-gzip', Path => "gzip < /home/agarcia/HoneyClient/backup-2008-06-11.tar |", ReadNow => 1, Filename => "SomeFile.tgz" ); $msg->add(From => "[EMAIL PROTECTED]"); $msg->add(To => "[EMAIL PROTECTED]"); $msg->add(Subject => "Test attach files"); ### Send the Message #MIME::Lite->send('smtp', honeyclient.seguridad.unam.mx, Timeout=>60); $msg->send; thanks for all and see you soon.... 2008/6/11 Rob Dixon <[EMAIL PROTECTED]>: > Armin Garcia wrote: > > Hi !!!! > > Well i try to attach a file, but i dont know what function or method i > need > > to use, here is my code, i hope anybody can help me .... thanks > > (im only want to attach files, thanlks ) > > > > > > #!/usr/bin/perl > > > > use Mail::Internet; > > use Mail::Box::Manager; > > use Email::Folder; > > > > $folder_file = "/home/agarcia/HoneyClient/Mbox-Folder/posible_spam"; > > $salida = > > > "/usr/local/Honeyclient/HoneyClient3/ScriptHoney/capture-server-2.1.0-300/Urls-Malware/filtrar.txt"; > > $UrlsFiltrar = > > > "/usr/local/Honeyclient/HoneyClient3/ScriptHoney/capture-server-2.1.0-300/Urls-Malware/Urls-Malware.txt"; > > > > # Abrimos el buzón. > > my $mgr = Mail::Box::Manager->new; > > $i=0; > > > > $folder = Email::Folder->new($folder_file); > > @urls = (); > > $dir; > > %Urls=(); > > if ( -e $salida ){ > > `rm -rf $salida`; > > } > > > > sub Parser { > > > > open (F,"< $salida") || die "No se pudo abrir el archivo"; > > @urls=<F>; > > $i=0; > > open (G, "> $UrlsFiltrar") || die "No se pudo crear"; > > foreach (@urls){ > > @aux=split(" ",@urls); > > $URLS{$urls[$i]}++; > > $i++; > > } > > foreach $var(keys %URLS){ > > print G "$var"; > > } > > close(F); > > close(G); > > } > > > > sub EnviarCorreo { > > $repfrom = shift(@_); > > $arch = shift (@_); > > $correos="[EMAIL PROTECTED]"; > > > > open(DATOS,$UrlsFiltrar); > > @body = <DATOS>; > > close(DATOS); > > > > open(MAIL, "| /usr/sbin/sendmail $correos"); > > print MAIL "From: [EMAIL PROTECTED]"; > > print MAIL "To: [EMAIL PROTECTED]"; > > print MAIL "Subject: test !!!!!\n\n"; > > print MAIL @body; > > close(MAIL); > > } > > > > for ($folder->messages) { > > for ( $_->body ) { > > if ( $_ =~ /http:/ ) { > > @urls = /(((ftp|http|https):\/\/|www\.)([\w*\-?\w*\.]+)*)/g; > > } > > } > > > > open (F," >> $salida") || die "No se puede crear el archivo ..."; > > foreach my $url (@urls) { > > print F "$url\n"; > > } > > close(F); > > } > > > > Parser; > > EnviarCorreo($salida); > > I'm afraid I can't understand your code. Others who are familiar with the > modules you are using may fare better, but I'm surprised that you need > three modules > > use Mail::Internet; > use Mail::Box::Manager; > use Email::Folder; > > to handle what seems to be a fairly simple task. > > First of all, please start with > > use strict; > use warnings; > > at the start of the program, and declare all variables as necessary. It > would > also help if you indented your code so that the block structure is > apparent. > > It is best practice to use scalar variables for file handles, to use the > three-parameter form of open, and provide the value of the error condition > $! in > your die string, so that > > open (G, "> $UrlsFiltrar") || die "No se pudo crear"; > > becomes > > open my $g, '>', $UrlsFiltrar or die "No se pudo crear: $!"; > > also > > open(DATOS,$UrlsFiltrar); > @body = <DATOS>; > close(DATOS); > > is neater as > > my @body = do { > open my $datos, '<', $UrlsFiltrar or die $!; > <$datos>; > }; > > Once you have made your code more visible I'm sure there are many others > who > will help you. > > HTH, > > Rob >