Author: jpeacock
Date: Thu Oct 26 08:50:02 2006
New Revision: 667

Modified:
   branches/0.3x/plugins/queue/postfix-queue

Log:
Add hardcoded mapping between postfix's cleanup errors and corresponding 
Qpsmtpd::DSN value.  (David Muir Sharnoff)

Modified: branches/0.3x/plugins/queue/postfix-queue
==============================================================================
--- branches/0.3x/plugins/queue/postfix-queue   (original)
+++ branches/0.3x/plugins/queue/postfix-queue   Thu Oct 26 08:50:02 2006
@@ -86,6 +86,39 @@
 
 # $self->log(LOGDEBUG, 
"queue-flags=".$transaction->notes('postfix-queue-flags'));
     my ($status, $qid, $reason) = Qpsmtpd::Postfix->inject_mail($transaction);
+    if ($status) {
+      # this section needs to be kept in sync with the cleanup_stat_map
+      # array found in Postfix source file src/global/cleanup_strerror.c
+      # which in turn uses constants defined in src/global/cleanup_user.h
+      if ($status & (1<<8)) {
+        # CLEANUP_STAT_DEFER
+        return(DENYSOFT, $reason || "service unavailable (#4.7.1)");
+      } elsif ($status & (1<<7)) {
+        # CLEANUP_STAT_PROXY
+        return(DENYSOFT, $reason || "proxy reject (#4.3.0)");
+      } elsif ($status & (1<<0)) {
+        # CLEANUP_STAT_BAD
+        return(DENYSOFT, $reason || "internal prototcal error (#4.3.0)");
+      } elsif ($status & (1<<6)) {
+        # CLEANUP_STAT_RCPT
+        return Qpsmtpd::DSN->addr_unspecified(DENY, $reason || "no recipients 
specified");
+      } elsif ($status & (1<<4)) {
+        # CLEANUP_STAT_HOPS
+        return Qpsmtpd::DSN->too_many_hops(DENY, $reason || "too many hops");
+      } elsif ($status & (1<<2)) {
+        # CLEANUP_STAT_SIZE
+        return Qpsmtpd::DSN->sys_msg_too_big(DENY, $reason || "message file 
too big");
+      } elsif ($status & (1<<3)) {
+        # CLEANUP_STAT_CONT
+        return Qpsmtpd::DSN->media_conv_prohibited(DENY, $reason || "message 
content rejected");
+      } elsif ($status & (1<<1)) {
+        # CLEANUP_STAT_WRITE
+        return (DECLINED, $reason || "queue file write error");
+      } else {
+        # we have no idea why we're here.
+        return (DECLINED, $reason || "unknown error from postfix/cleanup: 
$status");
+      }
+    }
     $status and return (DECLINED, "Unable to queue message ($status, 
$reason)");
 
     my $msg_id = $transaction->header->get('Message-Id') || '';

Reply via email to