| | |
| | | Pac pac = email.getDomain().getUser().getPac(); |
| | | CompoundProcessor cp = new CompoundProcessor(); |
| | | cp.appendProcessor(new ShellProcessor( "postmap -r -i /etc/postfix-mailin/virtual", |
| | | email.getFullDomain() + " -" ) ); |
| | | WaitingTasksProcessor waitingTasksProcessor = new WaitingTasksProcessor(cp); |
| | | email.getFullDomain() + " -" ) ); |
| | | Config config = Config.getInstance(); |
| | | cp.appendProcessor(new ShellProcessor( "postmap -r -i /etc/postfix-mailin/virtual", |
| | | email.getEMailAddress() + " " + email.getTarget() ) ); |
| | | WaitingTasksProcessor waitingTasksProcessor = new WaitingTasksProcessor(cp); |
| | | 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" ); |
| | |
| | | String domName = email.getDomain().getName(); |
| | | for (String queueName : config.getProperty("queues.mail").split(",")) { |
| | | waitingTasksProcessor.appendProcessor(queueName, createMailinSetupProcessor(domName, pac), queueName + ".hostsharing.net"); |
| | | } |
| | | return waitingTasksProcessor; |
| | | } else { |
| | | return cp; |
| | | } |
| | | } |
| | | return waitingTasksProcessor; |
| | | } |
| | | |
| | | public <T extends AbstractEntity> Processor createUpdateProcessor(EntityManager em, T entity) { |
| | |
| | | new ShellProcessor( "postmap -d '" + email.getEMailAddress() + "' /etc/postfix-mailin/relayrecipients" ), |
| | | "Remove from relayrecipients" ); |
| | | } |
| | | int emailAddressCount = emailAddressCount(em, email); |
| | | if (emailAddressCount == 0) { |
| | | if (emailAddressCount(em, email) == 0) { |
| | | // remove the domain from virtual.db |
| | | String fullDomain = email.getFullDomain(); |
| | | cp.appendProcessor( |
| | |
| | | for (String queueName : config.getProperty("queues.mail").split(",")) { |
| | | waitingTasksProcessor.appendProcessor(queueName, createMailinDeleteProcessor(fullDomain), queueName + ".hostsharing.net"); |
| | | } |
| | | return waitingTasksProcessor; |
| | | } else { |
| | | return cp; |
| | | } |
| | | return waitingTasksProcessor; |
| | | } |
| | | |
| | | private int emailAddressCount(EntityManager em, EMailAddress email) { |