boolean ehlo = false;
String remotehost = null;
String authenticatedAs = null;
+ int failedRcptCount = 0;
for(String command = conn.readln(); ; command = conn.readln()) try {
if (command == null) return;
Log.warn("**"+conn.getRemoteAddress()+"**", command);
command = command.substring(8).trim();
if(command.indexOf(' ') != -1) command = command.substring(0, command.indexOf(' '));
Address addr = new Address(command);
- if (addr.isLocal()) {
- // FEATURE: should check the address further and give 550 if undeliverable
- conn.println("250 " + addr + " is on this machine; I will deliver it");
- to.addElement(addr);
- } else if (conn.getRemoteAddress().isLoopbackAddress() || (from!=null&&from.toString().indexOf("johnw")!=-1)) {
+ if (conn.getRemoteAddress().isLoopbackAddress() || (from!=null&&from.toString().indexOf("johnw")!=-1)) {
conn.println("250 you are connected locally, so I will let you send");
to.addElement(addr);
- whitelist.addWhitelist(addr);
+ if (!whitelist.isWhitelisted(addr))
+ whitelist.addWhitelist(addr);
} else if (authenticatedAs!=null) {
conn.println("250 you are authenticated as "+authenticatedAs+", so I will let you send");
to.addElement(addr);
- whitelist.addWhitelist(addr);
+ if (!whitelist.isWhitelisted(addr))
+ whitelist.addWhitelist(addr);
+ } else if (addr.isLocal()) {
+ if (to.size() > 3) {
+ conn.println("536 sorry, limit on 3 RCPT TO's per DATA");
+ } else {
+ // FEATURE: should check the address further and give 550 if undeliverable
+ conn.println("250 " + addr + " is on this machine; I will deliver it");
+ to.addElement(addr);
+ }
} else {
conn.println("535 sorry, " + addr + " is not on this machine, you are not connected from localhost, and I will not relay without SMTP AUTH");
Log.warn("","535 sorry, " + addr + " is not on this machine, you are not connected from localhost, and I will not relay without SMTP AUTH");
+ failedRcptCount++;
+ if (failedRcptCount > 3) {
+ conn.close();
+ return;
+ }
}
conn.flush();
} else if (c.startsWith("DATA")) {