getLogger().error("Error parsing recipient address: "
+ recipient
+ ": did not start and end with < >");
return;
}
MailAddress recipientAddress = null;
//Remove < and >
recipient = recipient.substring(1, recipient.length() - 1);
if(recipient.indexOf("@")<0){
recipient = recipient+"@localhost";
}
try {
recipientAddress = new MailAddress(recipient);
} catch (Exception pe) {
out.println("501 Syntax error in parameters or arguments");
getLogger().error("Error parsing recipient address: "
+ recipient + ": " + pe.getMessage());
return;
}
// If this is a delivery failure notification (MAIL FROM: <>)
// we don't enforce authentication
if (authRequired && state.get(SENDER) != null) {
// Make sure the mail is being sent locally if not
// authenticated else reject.
if (!state.containsKey(AUTH)) {
String toDomain = recipientAddress.getHost();
if (!mailServer.isLocalServer(toDomain)) {
out.println("530 Authentication Required");
getLogger().error(
"Authentication is required for mail request");
return;
}
} else {
// Identity verification checking
if (verifyIdentity) {
String authUser = (String)state.get(AUTH);
MailAddress senderAddress
= (MailAddress)state.get(SENDER);
boolean domainExists = false;
if (!authUser.equalsIgnoreCase(
senderAddress.getUser())) {
out.println("503 Incorrect Authentication for Specified Email Address");
getLogger().error("User " + authUser
+ " authenticated, however tried sending email as "
+ senderAddress);
return;
}
if (!mailServer.isLocalServer(
senderAddress.getHost())) {
out.println("503 Incorrect Authentication for Specified Email Address");
getLogger().error("User " + authUser
+ " authenticated, however tried sending email as "
+ senderAddress);
return;