Use the Mail::Sender Module, is to easy with it
(ref ($sender->MailFile(
{to =>'[EMAIL PROTECTED]', subject => 'this is a test',
msg => "Hi Johnie.\nI'm sending you the pictures you wanted.",
file => 'image1.jpg,image2.jpg'
}))
and print "Mail sent OK."
)
or die "$Mail::Sender::Error\n";
On Fri, Jun 20, 2008 at 10:04 AM, Rob Dixon <[EMAIL PROTECTED]> wrote:
> Armin Garcia wrote:
>>
>> well i have some problems again, thats my new code:
>>
>>
>> #!/usr/bin/perl -w
>
> Drop the -w qualifer from this line. It is best done with 'use warnings' that
> you have below.
>
> Also
>
> use strict;
> use warnings;
>
> here instead of after including MIME::Lite.
>
>> #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";
>
> Once you have used strict, all variables need declaring using my.
>
> There is no need to escape the hyphen here, and also since you aren't using
> interpolation it's best to use single quotes.
>
> my $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`;
>
> I don't know what this does, but it's likely to be better to write it in Perl.
>
>> 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();
>
> This looks like a C programming habit. It's more conventional in Perl to put
> all
> the main code at the top of the program and not wrap it as a subroutine.
>
>>
>> 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
>> !!!
>> *
>
> We can't help you much further as you haven't posted the code that's causing
> you
> problems. Try implementing the suggestions above and see where that leads you.
>
> Rob
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> http://learn.perl.org/
>
>
>
--
David Romero
www.factufacil.com.mx
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/