summaryrefslogtreecommitdiffstats
path: root/perl-install/standalone/logdrake
diff options
context:
space:
mode:
authorThierry Vignaud <tvignaud@mandriva.org>2004-02-02 17:56:36 +0000
committerThierry Vignaud <tvignaud@mandriva.org>2004-02-02 17:56:36 +0000
commit7625e6ccbeaec8c61c597c6367ec9c6afd8f3a5b (patch)
tree478fbe4923eb1569fc20b8b6f5721354e98bcc22 /perl-install/standalone/logdrake
parent992308b51918c7929c235a89ffaaecb85649df66 (diff)
downloaddrakx-7625e6ccbeaec8c61c597c6367ec9c6afd8f3a5b.tar
drakx-7625e6ccbeaec8c61c597c6367ec9c6afd8f3a5b.tar.gz
drakx-7625e6ccbeaec8c61c597c6367ec9c6afd8f3a5b.tar.bz2
drakx-7625e6ccbeaec8c61c597c6367ec9c6afd8f3a5b.tar.xz
drakx-7625e6ccbeaec8c61c597c6367ec9c6afd8f3a5b.zip
make cron script be able to use either local smtp server or a remote
one (arnaud)
Diffstat (limited to 'perl-install/standalone/logdrake')
-rwxr-xr-xperl-install/standalone/logdrake31
1 files changed, 19 insertions, 12 deletions
diff --git a/perl-install/standalone/logdrake b/perl-install/standalone/logdrake
index 455598e04..d34f6beef 100755
--- a/perl-install/standalone/logdrake
+++ b/perl-install/standalone/logdrake
@@ -349,6 +349,7 @@ sub alert_config() {
my %options = getVarsFromSh($conffile);
$options{LOAD} ||= 3;
$options{MAIL} ||= "root";
+ $options{SMTP} ||= "localhost";
my $service = {
httpd => N("Apache World Wide Web Server"),
@@ -403,17 +404,22 @@ sub alert_config() {
},
email => {
name => N("Alert configuration") . "\n\n" .
- N("Please enter your email address below "),
+ N("Please enter your email address below ") . "\n" .
+ N("and enter the name (or the IP) of the smtp server you whish to use"),
data => [
- { label => "Email", val => \$options{MAIL},
- },
+ { label => "Email address", val => \$options{MAIL} },
+ { label => "Email server", val => \$options{SMTP} },
],
complete => sub {
if ($options{MAIL} !~ /[\w.-]*\@[\w.-]/ && !member($options{MAIL}, map { $_->[0] } list_passwd())) {
- err_dialog(N("Wrong email"), N("\"%s\" neither is a valid email nor is an existing local user!",
+ err_dialog(N("Error"), N("\"%s\" neither is a valid email nor is an existing local user!",
$options{MAIL}));
return 1;
}
+ if (member($options{MAIL}, map { $_->[0] } list_passwd()) && $options{SMP} !~ /localhost/) {
+ err_dialog(N("Error"), N("\"%s\" is a local user but you did not select a local smtp, so you must use a complete email address!", $options{MAIL}));
+ return 1;
+ }
},
next => "end",
},
@@ -457,14 +463,15 @@ $r .= "Load is huge: $load\n" if $load > $options{LOAD};
#- report it
if ($r) {
- my $F;
- open $F, '|/usr/sbin/sendmail -oi -t';
- print $F qq(Subject: logdrake Mail Alert
-From: root\@localhost
-To: $options{MAIL}
-);
- print $F "*** " . chomp_(`date`) . " ***\n";
- print $F $r;
+ use Mail::Mailer;
+ my $mailer = Mail::Mailer->new('smtp', Server => $options{SMTP});
+ $mailer->open({ From => 'root@localhost',
+ To => $options{MAIL},
+ Subject => "DrakLog Mail Alert",
+ })
+ or die "Can't open: $!\n";
+ print $mailer $r;
+ $mailer->close;
}
# EOF);