}
}
- public static boolean attempt(Message m) throws IOException {
+ public static boolean attempt(Message m) throws IOException { return attempt(m, false); }
+ public static boolean attempt(Message m, boolean noBounces) throws IOException {
if (m.envelopeTo == null) {
Log.warn(SMTP.Outgoing.class, "aieeee, null envelopeTo: " + m.summary());
return false;
}
InetAddress[] mx = getMailExchangerIPs(m.envelopeTo.host);
if (mx.length == 0) {
- accept(m.bounce("could not resolve " + m.envelopeTo.host));
- return true;
+ if (!noBounces) {
+ accept(m.bounce("could not resolve " + m.envelopeTo.host));
+ return true;
+ } else {
+ Log.warn(SMTP.Outgoing.class, "could not resolve " + m.envelopeTo.host);
+ return false;
+ }
}
if (new Date().getTime() - m.arrival.getTime() > 1000 * 60 * 60 * 24 * 5) {
- accept(m.bounce("could not send for 5 days"));
- return true;
+ if (!noBounces) {
+ accept(m.bounce("could not send for 5 days"));
+ return true;
+ } else {
+ Log.warn(SMTP.Outgoing.class, "could not send for 5 days: " + m.summary());
+ return false;
+ }
}
for(int i=0; i<mx.length; i++) {
//if (deadHosts.contains(mx[i])) continue;
Log.warn(SMTP.Outgoing.class, e);
if (e.code >= 500 && e.code <= 599) {
try {
- accept(m.bounce("unable to deliver: " + e));
+ attempt(m.bounce("unable to deliver: " + e), true);
} catch (Exception ex) {
- Log.error(SMTP.Outgoing.class, "very serious: exception while trying to deliver bounce");
+ Log.error(SMTP.Outgoing.class, "exception while trying to deliver bounce; giving up completely");
Log.error(SMTP.Outgoing.class, ex);
}
return true;