Processes the message. Checks which command was sent based on the
recipient address, and does the appropriate action.
if (mail.getRecipients().size() != 1) {
getMailetContext().bounce(mail, "You can only send one command at a time to this listserv manager.");
return;
}
MailAddress address = (MailAddress)mail.getRecipients().iterator().next();
if (address.getUser().endsWith("-off")) {
if (existsAddress(mail.getSender())) {
if (removeAddress(mail.getSender())) {
getMailetContext().bounce(mail, "Successfully removed from listserv.");
} else {
getMailetContext().bounce(mail, "Unable to remove you from listserv for some reason.");
}
} else {
getMailetContext().bounce(mail, "You are not subscribed to this listserv.");
}
} else if (address.getUser().endsWith("-on")) {
if (existsAddress(mail.getSender())) {
getMailetContext().bounce(mail, "You are already subscribed to this listserv.");
} else {
if (addAddress(mail.getSender())) {
getMailetContext().bounce(mail, "Successfully added to listserv.");
} else {
getMailetContext().bounce(mail, "Unable to add you to the listserv for some reason");
}
}
} else {
getMailetContext().bounce(mail, "Could not understand the command you sent to this listserv manager.\r\n"
+ "Valid commands are <listserv>-on@domain.com and <listserv>-off@domain.com");
}
//Kill the command message
mail.setState(Mail.GHOST);