in reply to Log4Perl to send mail via SMTP

Am am successfully using Log4perl to send email using the following appender:
log4perl.logger=ERROR, Mailer log4perl.appender.Mailer = Log::Dispatch::Email::MailSend # only mail ERRORs and above: log4perl.appender.Mailer.Threshold = ERROR log4perl.appender.Mailer.to = x@y.z log4perl.appender.Mailer.subject = db error log4perl.appender.Mailer.buffered = 0 log4perl.appender.Mailer.layout = PatternLayout log4perl.appender.Mailer.layout.ConversionPattern=%d %p> %F{1}:%L %M - + %m%n

Replies are listed 'Best First'.
Re^2: Log4Perl to send mail via SMTP
by weismat (Friar) on Nov 21, 2008 at 02:23 UTC
    I think that the main problem is that Log4Perl can only call the constructor with key-value pairs, unfortunately Mail:Mailer uses smtp as a scalar parameter.
    The documentation mentions the following:
    Since Mail::Send is a subclass of Mail::Mailer, you can change how mail is sent from this module by simply useing Mail::Mailer in your code before mail is sent. For example, to send mail via smtp, you could do:
    use Mail::Mailer 'smtp', Server => 'foo.example.com';
    I do not understand this part of the docu. Could one explaint it to me?
      #!/usr/bin/perl ... this is your code, to it you add the following use Mail::Mailer 'smtp', Server => 'foo.example.com';
        I tried this and received:
        Cannot locate 'Server' at log4Perl.pl line 1
        Warning: something's wrong at /opt/ActivePerl-5.8/site/lib/Mail/Mailer.pm line 278.
        Broken Pipe