diff --git a/hsarback/src/de/hsadmin/mods/email/EMailAddressProcessorFactory.java b/hsarback/src/de/hsadmin/mods/email/EMailAddressProcessorFactory.java index 71ada28..34d0988 100644 --- a/hsarback/src/de/hsadmin/mods/email/EMailAddressProcessorFactory.java +++ b/hsarback/src/de/hsadmin/mods/email/EMailAddressProcessorFactory.java @@ -23,12 +23,16 @@ public class EMailAddressProcessorFactory implements EntityProcessorFactory { CompoundProcessor cp = new CompoundProcessor(); cp.appendProcessor(new ShellProcessor( "postmap -r -i /etc/postfix-mailin/virtual", email.getFullDomain() + " -" ) ); + WaitingTasksProcessor waitingTasksProcessor = new WaitingTasksProcessor(cp); + Config config = Config.getInstance(); cp.appendProcessor(new ShellProcessor( "postmap -r -i /etc/postfix-mailin/virtual", email.getEMailAddress() + " " + email.getTarget() ) ); - if (emailAddressCount(em, email) < 2) { - WaitingTasksProcessor waitingTasksProcessor = new WaitingTasksProcessor(cp); - String domName = email.getDomain().getName(); - Config config = Config.getInstance(); + for (String queueName : config.getProperty("queues.mail").split(",")) { + waitingTasksProcessor.appendProcessor(queueName, new ShellProcessor( "postmap -r -i /etc/postfix-mailin/relayrecipients", + email.getEMailAddress() + " anything" ), "Add to relayrecipients" ); + } + if (emailAddressCount(em, email) <= 1) { + String domName = email.getDomain().getName(); for (String queueName : config.getProperty("queues.mail").split(",")) { waitingTasksProcessor.appendProcessor(queueName, createMailinSetupProcessor(domName, pac), queueName + ".hostsharing.net"); } @@ -49,14 +53,18 @@ public class EMailAddressProcessorFactory implements EntityProcessorFactory { EMailAddress email = (EMailAddress) entity; cp.appendProcessor( new ShellProcessor( "postmap -d '" + email.getEMailAddress() + "' /etc/postfix-mailin/virtual" ) ); + Config config = Config.getInstance(); + WaitingTasksProcessor waitingTasksProcessor = new WaitingTasksProcessor(cp); + for (String queueName : config.getProperty("queues.mail").split(",")) { + waitingTasksProcessor.appendProcessor(queueName, + new ShellProcessor( "postmap -d '" + email.getEMailAddress() + "' /etc/postfix-mailin/relayrecipients" ), "Remove from relayrecipients" ); + } int emailAddressCount = emailAddressCount(em, email); if (emailAddressCount == 0) { // remove the domain from virtual.db String fullDomain = email.getFullDomain(); cp.appendProcessor( - new ShellProcessor( "postmap -d '" + fullDomain + "' /etc/postfix-mailin/virtual" ) ); - WaitingTasksProcessor waitingTasksProcessor = new WaitingTasksProcessor(cp); - Config config = Config.getInstance(); + new ShellProcessor( "postmap -d '" + fullDomain + "' /etc/postfix-mailin/virtual" ) ); for (String queueName : config.getProperty("queues.mail").split(",")) { waitingTasksProcessor.appendProcessor(queueName, createMailinDeleteProcessor(fullDomain), queueName + ".hostsharing.net"); }