Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??
thank you all!

now i have another problem. if the word is found, i need to send an email.

on perl.org/exemples i have found the following code:

#!/usr/bin/perl use strict; use warnings; # first, create your message use Email::MIME; my $message = Email::MIME->create( header_str => [ From => 'you@example.com', To => 'friend@example.com', Subject => 'Happy birthday!', ], attributes => { encoding => 'quoted-printable', charset => 'ISO-8859-1', }, body_str => "Happy birthday to you!\n", ); # send the message use Email::Sender::Simple qw(sendmail); sendmail($message);


and i have implemented it in my code as:

#!/usr/bin/perl use strict; use warnings; use Email::MIME; print "searching using regexp...\n"; open(my $in, "<", "DirectX.log") or die "Can't open DirectX.log: $! +"; while (<$in>) { if ($_ =~ /eroare+/) { print "found eroare\n"; my $message = Email::MIME->create( header_str => [ From => 'alexandru.fatu@hotmail.com', To => 'alexandru.fatu@hotmail.com', Subject => 'Error!', ], attributes => { encoding => 'quoted-printable', charset => 'ISO-8859-1', }, body_str => "Eroare gasita: $_", ); # send the message use Email::Sender::Simple qw(sendmail); sendmail($message); } } close $in or die "$in: $!";


After downloading Email::MIME and all dependencies (email::address, email::sample and many more..) i get an error:
unable to establish SMTP connection

Trace begun at C:\strawberry\perl\site\lib\Email\Sender\Transport\SMTP +.pm line 9 6 Email::Sender::Transport::SMTP::_throw('Email::Sender::Transport::SMTP +=HASH(0x1e 3e90c)', 'unable to establish SMTP connection') called at C:\strawberr +y\perl\sit e\lib\Email\Sender\Transport\SMTP.pm line 63 Email::Sender::Transport::SMTP::_smtp_client('Email::Sender::Transport +::SMTP=HAS H(0x1e3e90c)') called at C:\strawberry\perl\site\lib\Email\Sender\Tran +sport\SMTP .pm line 105 Email::Sender::Transport::SMTP::send_email('Email::Sender::Transport:: +SMTP=HASH( 0x1e3e90c)', 'Email::Abstract=ARRAY(0x1d4132c)', 'HASH(0x1ca4bec)') ca +lled at C: \strawberry\perl\site\lib\Email\Sender\Role\CommonSending.pm line 27 Email::Sender::Role::CommonSending::__ANON__ at C:\strawberry\perl\ven +dor\lib\Tr y\Tiny.pm line 76 eval {...} at C:\strawberry\perl\vendor\lib\Try\Tiny.pm line 67 Try::Tiny::try('CODE(0x1e471a4)', 'Try::Tiny::Catch=REF(0x1e31c14)') c +alled at C :\strawberry\perl\site\lib\Email\Sender\Role\CommonSending.pm line 40 Email::Sender::Role::CommonSending::send('Email::Sender::Transport::SM +TP=HASH(0x 1e3e90c)', 'Email::Abstract=ARRAY(0x1d4132c)', 'HASH(0x1e4503c)') call +ed at C:\s trawberry\perl\site\lib\Email\Sender\Simple.pm line 115 Email::Sender::Simple::send_email('Email::Sender::Simple', 'Email::Abs +tract=ARRA Y(0x1d4132c)', 'HASH(0x1d3d77c)') called at C:\strawberry\perl\site\li +b\Email\Se nder\Role\CommonSending.pm line 27 Email::Sender::Role::CommonSending::__ANON__ at C:\strawberry\perl\ven +dor\lib\Tr y\Tiny.pm line 76 eval {...} at C:\strawberry\perl\vendor\lib\Try\Tiny.pm line 67 Try::Tiny::try('CODE(0x1be23ec)', 'Try::Tiny::Catch=REF(0x1d2fb8c)') c +alled at C :\strawberry\perl\site\lib\Email\Sender\Role\CommonSending.pm line 40 Email::Sender::Role::CommonSending::send('Email::Sender::Simple', 'Ema +il::MIME=H ASH(0x1d4127c)') called at C:\strawberry\perl\vendor\lib\Sub\Exporter\ +Util.pm li ne 18 Sub::Exporter::Util::__ANON__('Email::MIME=HASH(0x1d4127c)') called at + bebe1.pl line 35


Please, tell me where do i need to put my email, my password etc..setting for sending an email.

BR,
Alex

In reply to Re: log parser by alex_fatu
in thread log parser by alex_fatu

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others avoiding work at the Monastery: (6)
    As of 2015-07-06 05:26 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









      Results (70 votes), past polls