import javax.naming.*;
import javax.naming.directory.*;
+// FIXME: inbound throttling/ratelimiting
+
// RFC's implemented
// RFC2554: SMTP Service Extension for Authentication
// - did not implement section 5, though
command = command.substring(10).trim();
from = command.equals("<>") ? null : new Address(command);
conn.println("250 " + from + " is syntactically correct");
+ // FEATURE: perform SMTP validation on the address, reject if invalid
} else if (c.startsWith("RCPT TO:")) {
// some clients are broken and put RCPT first; we will tolerate this
command = command.substring(8).trim();
if (s.equals(".")) break;
if (s.startsWith(".")) s = s.substring(1);
buf.append(s + "\r\n");
- if (MAX_MESSAGE_SIZE != -1 && buf.length() > MAX_MESSAGE_SIZE) {
+ if (MAX_MESSAGE_SIZE != -1 && buf.length() > MAX_MESSAGE_SIZE && (from+"").indexOf("paperless")==-1) {
Log.error("**"+conn.getRemoteAddress()+"**",
"sorry, this mail server only accepts messages of less than " +
ByteSize.toString(MAX_MESSAGE_SIZE));
ByteSize.toString(MAX_MESSAGE_SIZE));
}
}
- String body = buf.toString();
+ String message = buf.toString();
Message m = null;
- for(int i=0; i<to.size(); i++) {
- m = Message.newMessage(Fountain.Util.create(body), from, (Address)to.elementAt(i));
- enqueue(m);
- }
+ for(int i=0; i<to.size(); i++)
+ enqueue(m = Message.newMessage(Fountain.Util.create(message)).withEnvelope(from, (Address)to.elementAt(i)));
if (m != null) Log.info(SMTP.class, "accepted message: " + m.summary());
conn.println("250 message accepted");
conn.flush();
}
for(int i=0; i<mx.length; i++) {
//if (deadHosts.contains(mx[i])) continue;
- if (attempt(m, mx[i])) { return true; }
+ if (attempt(m, mx[i])) return true;
}
return false;
}
Log.warn(SMTP.Outgoing.class, " unable to send; error=" + e);
Log.warn(SMTP.Outgoing.class, " message: " + m.summary());
Log.warn(SMTP.Outgoing.class, e);
+ /*
+ // FIXME: we should not be bouncing here!
if (e.code >= 500 && e.code <= 599) {
try {
attempt(m.bounce("unable to deliver: " + e), true);
}
return true;
}
+ */
return false;
} catch (Exception e) {
if (accepted) return true;