[projects/distfiles] Send report mails separately to requester and list

baggins baggins at pld-linux.org
Sat Oct 18 15:05:42 CEST 2014


commit 472da1dad32b99444435e1769718fe45758ff761
Author: Jan Rękorajski <baggins at pld-linux.org>
Date:   Sat Oct 18 15:05:22 2014 +0200

    Send report mails separately to requester and list
    
    "Some" mail providers do deduplication solely based on the
    message-id, thus making mail sent to list and requester show
    only once if requester is subscribed to list.
    By sending two mails with different message-id we can work
    around this.

 file-fetcher.pl    | 42 ++++++++++++++++++++++++++++++++----------
 request-handler.pl | 39 ++++++++++++++++++++++++++-------------
 2 files changed, 58 insertions(+), 23 deletions(-)
---
diff --git a/file-fetcher.pl b/file-fetcher.pl
index 09cdfaa..78aecf0 100755
--- a/file-fetcher.pl
+++ b/file-fetcher.pl
@@ -358,9 +358,6 @@ sub fetch_files()
 
 sub send_email()
 {
-  syslog("info","sending email to $requester");
-  open(EMAIL, "| /usr/sbin/sendmail -t");
-  #open(EMAIL, "| cat");
   my $marker = "";
   if ($problems ne "") {
     $marker = "ERRORS: ";
@@ -371,16 +368,14 @@ sub send_email()
   splice(@files, 10, @files - 10, "...")
     if (@files > 10);
 
-  print EMAIL
+  my $message_id = 
+  my $email_head =
 "From: $req_login <$requester>
-To: $commits_list
-Cc: $requester
 Subject: DISTFILES: ${spec}: ${marker}@{files}
-Message-ID: <$$." . time . "\@distfiles.pld-linux.org>
 X-distfiles-program: file-fetcher.pl
-X-distfiles-version: " . '$Id$' . "
-
-$problems
+";
+  my $email_body =
+"$problems
 Files fetched: $fetched_count
 
 $normal_out
@@ -388,6 +383,33 @@ $normal_out
 -- 
 Virtually Yours: distfiles.
 ";
+
+  syslog("info","sending email to $requester");
+  open(EMAIL, "| /usr/sbin/sendmail -t");
+  #open(EMAIL, "| cat");
+
+  print EMAIL
+"To: $requester
+$email_head
+Message-ID: <$$." . time . "\@distfiles.pld-linux.org>
+
+$email_body";
+
+  close(EMAIL) or fatal("close() failed");
+
+  syslog("info","sending email to $commits_list");
+  open(EMAIL, "| /usr/sbin/sendmail -t");
+  #open(EMAIL, "| cat");
+
+  print EMAIL
+"To: $commits_list
+$email_head
+Message-ID: <$$." . time . "\@distfiles.pld-linux.org>
+
+Request by: $requester
+
+$email_body";
+
   close(EMAIL) or fatal("close() failed");
 }
 
diff --git a/request-handler.pl b/request-handler.pl
index 347233e..dfcd273 100755
--- a/request-handler.pl
+++ b/request-handler.pl
@@ -29,24 +29,37 @@ sub report_fatal($)
 
   syslog("err","FATAL: $msg");
   cleanup();
-  open(M, "| /usr/sbin/sendmail -t") or die("/usr/sbin/sendmail not found");
-  #open(M, "| cat") or die;
-  my $version = '$Id$';
-  print M <<EOF
-From: $from <$from\@pld-linux.org>
-To: $commits_list
-Cc: $from\@pld-linux.org
-Message-ID: <$id\@distfiles.pld-linux.org>
+
+  my $email_head =
+"From: $from <$from\@pld-linux.org>
 Subject: DISTFILES: ERROR fetching sources for $spec ($branch)
 X-distfiles-program: request-handler.pl
-X-distfiles-version: $version
-
-$msg
+";
+  my $email_body =
+"$msg
 
 -- 
 Virtually Yours: distfiles.
-EOF
-;
+";
+
+  open(M, "| /usr/sbin/sendmail -t") or die("/usr/sbin/sendmail not found");
+  #open(M, "| cat") or die;
+  print M
+"To: $commits_list
+$email_head
+Message-ID: <$$." . time . "$id\@distfiles.pld-linux.org>
+
+$email_body";
+  close(M) or die("problem while sending email");
+  
+  open(M, "| /usr/sbin/sendmail -t") or die("/usr/sbin/sendmail not found");
+  #open(M, "| cat") or die;
+  print M
+"To: <$from\@pld-linux.org>
+$email_head
+Message-ID: <$$." . time . "$id\@distfiles.pld-linux.org>
+
+$email_body";
   close(M) or die("problem while sending email");
   exit 0;
 }
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/projects/distfiles.git/commitdiff/472da1dad32b99444435e1769718fe45758ff761



More information about the pld-cvs-commit mailing list