aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorPascal Terjan <pterjan@mageia.org>2012-01-02 17:29:40 +0000
committerPascal Terjan <pterjan@mageia.org>2012-01-02 17:29:40 +0000
commit7de111b45234089eeca433c9ceba9566017beba5 (patch)
treec9c789f21e5820ed8ab67199be1f8eaff61cb52d /lib
parent8e112e04c1dbdbe2721f24621532bddb4eeafa26 (diff)
downloadiurt-7de111b45234089eeca433c9ceba9566017beba5.tar
iurt-7de111b45234089eeca433c9ceba9566017beba5.tar.gz
iurt-7de111b45234089eeca433c9ceba9566017beba5.tar.bz2
iurt-7de111b45234089eeca433c9ceba9566017beba5.tar.xz
iurt-7de111b45234089eeca433c9ceba9566017beba5.zip
Append domain when sending emails to user
Diffstat (limited to 'lib')
-rw-r--r--lib/Iurt/Config.pm5
-rw-r--r--lib/Iurt/DKMS.pm2
-rw-r--r--lib/Iurt/Mail.pm24
-rw-r--r--lib/Iurt/Process.pm8
4 files changed, 29 insertions, 10 deletions
diff --git a/lib/Iurt/Config.pm b/lib/Iurt/Config.pm
index 7093d1d..2005542 100644
--- a/lib/Iurt/Config.pm
+++ b/lib/Iurt/Config.pm
@@ -239,9 +239,8 @@ sub get_maint {
}
my $maint = `GET 'http://maintdb.mageia.org/$srpm_name'`;
chomp $maint;
- my $email_maint = $maint . '@mageia.org';
- $run->{maint}{$srpm} = $email_maint;
- $email_maint, $srpm_name;
+ $run->{maint}{$srpm} = $maint;
+ $maint, $srpm_name;
}
sub get_author_email {
diff --git a/lib/Iurt/DKMS.pm b/lib/Iurt/DKMS.pm
index 7410008..868770c 100644
--- a/lib/Iurt/DKMS.pm
+++ b/lib/Iurt/DKMS.pm
@@ -262,7 +262,7 @@ sub dkms_compile {
"Modules for $name have been built for the current kernel ($kerver) while they should have been build for $modulesdir.",
"Please report to the maintainer of $name",
)),
- "Iurt the rebuild bot <$config->{admin}>", 0);
+ "Iurt the rebuild bot <$config->{admin}>", 0, $config);
next;
}
diff --git a/lib/Iurt/Mail.pm b/lib/Iurt/Mail.pm
index b805db2..6a9edb6 100644
--- a/lib/Iurt/Mail.pm
+++ b/lib/Iurt/Mail.pm
@@ -8,15 +8,35 @@ our @EXPORT = qw(
sendmail
);
+sub expand_email {
+ my($email, $config) = @_;
+ return $email unless $config->{email_domain};
+ my $name = "";
+ my $addr = $email;
+ if ($email =~ /^(.*)<(.*)>$/) {
+ $name = $1;
+ $addr = $2;
+ }
+ if ($addr =~ /@/) {
+ return $email;
+ }
+ return "$name<$addr\@$config->{email_domain}>";
+}
+
sub sendmail {
- my ($to, $cc, $subject, $text, $from, $debug) = @_;
+ my ($to, $cc, $subject, $text, $from, $debug, $config) = @_;
do { print "Cannot find sender-email-address [$to]\n"; return } unless defined($to);
my $MAIL;
if (!$debug) { open $MAIL, "| /usr/sbin/sendmail -t" or return } else { open $MAIL, ">&STDOUT" or return }
+ $to = expand_email($to, $config);
my $sender = encode_mimewords($to);
$subject = encode_mimewords($subject);
print $MAIL "To: $sender\n";
- if ($cc) { $cc = encode_mimewords($cc); print $MAIL "Cc: $cc\n" }
+ if ($cc) {
+ $cc = expand_email($cc, $config);
+ $cc = encode_mimewords($cc);
+ print $MAIL "Cc: $cc\n"
+ }
print $MAIL "From: $from\n";
print $MAIL "Subject: $subject\n";
print $MAIL "\n";
diff --git a/lib/Iurt/Process.pm b/lib/Iurt/Process.pm
index ff95428..88aa544 100644
--- a/lib/Iurt/Process.pm
+++ b/lib/Iurt/Process.pm
@@ -234,7 +234,7 @@ sub perform_command {
sendmail($config->{admin}, '' ,
"$opt{hash} on $run->{my_arch} for $run->{media}: broken pipe",
"$comment\n$output", "Iurt the build bot <$config->{admin}>",
- $opt{debug_mail});
+ $opt{debug_mail}, $config);
} else {
if ($opt{type} eq 'shell') {
$comment = "Command failed: $command\n";
@@ -255,7 +255,7 @@ sub perform_command {
}
plog('ERR', "ERROR: $wr !");
- sendmail($config->{admin}, '' , "$opt{hash} on $run->{my_arch} for $run->{media}: could not proceed", "$wr\n\n$comment\n$output", "Iurt the rebuild bot <$config->{admin}>", $opt{debug_mail}) if $opt{wait_mail};
+ sendmail($config->{admin}, '' , "$opt{hash} on $run->{my_arch} for $run->{media}: could not proceed", "$wr\n\n$comment\n$output", "Iurt the rebuild bot <$config->{admin}>", $opt{debug_mail}, $config) if $opt{wait_mail};
}
}
}
@@ -287,9 +287,9 @@ sub perform_command {
if ($opt{mail} && $config->{sendmail} && !$config->{no_mail}{$opt{mail}}) {
if (! ($cache->{warning}{$opt{hash}}{$opt{mail}} % $opt{freq})) {
my $cc = join ',', grep { !$config->{no_mail}{$_} } split ',', $opt{cc};
- sendmail($opt{mail}, $cc, $opt{error} , "$comment\n$out", "Iurt the rebuild bot <$config->{admin}>", $opt{debug_mail});
+ sendmail($opt{mail}, $cc, $opt{error} , "$comment\n$out", "Iurt the rebuild bot <$config->{admin}>", $opt{debug_mail}, $config);
} elsif ($config->{admin}) {
- sendmail($config->{admin}, '' , $opt{error}, "$comment\n$out", "Iurt the rebuild bot <$config->{admin}>", $opt{debug_mail});
+ sendmail($config->{admin}, '' , $opt{error}, "$comment\n$out", "Iurt the rebuild bot <$config->{admin}>", $opt{debug_mail}, $config);
}
}
$cache->{warning}{$opt{hash}}{$opt{mail}}++;