Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?

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 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 => '', To => '', 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 => '', To => '', 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 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\ 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\ line 27 Email::Sender::Role::CommonSending::__ANON__ at C:\strawberry\perl\ven +dor\lib\Tr y\ line 76 eval {...} at C:\strawberry\perl\vendor\lib\Try\ line 67 Try::Tiny::try('CODE(0x1e471a4)', 'Try::Tiny::Catch=REF(0x1e31c14)') c +alled at C :\strawberry\perl\site\lib\Email\Sender\Role\ 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\ 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\ line 27 Email::Sender::Role::CommonSending::__ANON__ at C:\strawberry\perl\ven +dor\lib\Tr y\ line 76 eval {...} at C:\strawberry\perl\vendor\lib\Try\ line 67 Try::Tiny::try('CODE(0x1be23ec)', 'Try::Tiny::Catch=REF(0x1d2fb8c)') c +alled at C :\strawberry\perl\site\lib\Email\Sender\Role\ 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\ li ne 18 Sub::Exporter::Util::__ANON__('Email::MIME=HASH(0x1d4127c)') called at + line 35

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


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

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!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • 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?

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

    How do I use this? | Other CB clients
    Other Users?
    Others drinking their drinks and smoking their pipes about the Monastery: (4)
    As of 2016-02-13 11:12 GMT
    Find Nodes?
      Voting Booth?

      How many photographs, souvenirs, artworks, trophies or other decorative objects are displayed in your home?

      Results (427 votes), past polls