proper handling of SMTP 5xx messages
authoradam <adam@megacz.com>
Sun, 26 Feb 2006 04:07:55 +0000 (04:07 +0000)
committeradam <adam@megacz.com>
Sun, 26 Feb 2006 04:07:55 +0000 (04:07 +0000)
darcs-hash:20060226040755-5007d-2d7e863b0ca82a3a6f48df6f265a6ed491adc66b.gz

src/org/ibex/mail/protocol/SMTP.java

index 32c25f6..18d49db 100644 (file)
@@ -242,6 +242,21 @@ public class SMTP {
                 Log.warn(SMTP.Outgoing.class, "success: " + mx + " accepted " + m.summary() + "\n["+resp+"]");
                 accepted = true;
                 conn.close();
+            } catch (SMTPException e) {
+                if (accepted) return true;
+                Log.warn(SMTP.Outgoing.class, "    unable to send; error=" + e);
+                Log.warn(SMTP.Outgoing.class, "      message: " + m.summary());
+                Log.warn(SMTP.Outgoing.class, e);
+                if (e.code >= 500 && e.code <= 599) {
+                    try {
+                        accept(m.bounce("unable to deliver: " + e));
+                    } catch (Exception ex) {
+                        Log.error(SMTP.Outgoing.class, "very serious: exception while trying to deliver bounce");
+                        Log.error(SMTP.Outgoing.class, ex);
+                    }
+                    return true;
+                }
+                return false;
             } catch (Exception e) {
                 if (accepted) return true;
                 Log.warn(SMTP.Outgoing.class, "    unable to send; error=" + e);