Closed teodorescuserban closed 12 years ago
i found a solution here: http://www.ipsure.com/blog/2012/enabling-roundcube-vacation-removes-actual-postfixadmin-aliases/ but it's pretty ugly and you need to do supplemental operations each time you add another mailbox/alias.
With my old version of postfixadmin and the old SQL schema, the alias entry is not needed if the vacation is not enabled.
In your case, you can add a conditional INSERT request in $rcmail_config['vacation_sql_write'] :
INSERT INTO alias (address,goto,domain,created,modified,active) SELECT %email,%email,%email_domain,NOW(),NOW(),0 FROM mailbox WHERE username=%email AND domain=%email_domain AND %vacation_enable=0;
Thanks I was having the same issue and the above seems to fix it. Also is it possible to retain forwardings. I mean if you setup a forwarding address and then setup vacation, the forwarding gets overwritten by the vacation plugin. Even the above fix will not retain the forwardings. Some one has raised a pull request, have tried his option but doesn't seem to work. Basically the plugin shlould retain all previous aliases and shld add or remove only the autoreply email address.
regards,
Alienglow
In my rush after a good vacation plugin, I forgot to mention that this is a great plugin :) Thank you for your efforts. I will try to add at the end of the $rcmail_config['vacation_sql_write'] array the insert you mentioned. Indeed, best solution I think it would be, as mentioned by alienglow, to just strip the autoresponder part from alias when vacation is disabled. This way, there can be any number of alias mangling (forwarding, etc) that this plugin will not break. Again, thanks for your work! :)
After playing a bit with the reads and writes, i come up with this (see below). I know for a fact that each mailbox in a postfixadmin installation has an alias pointing toward itself. On that, i can add a vacation-specific alias or a normal forwarder. I am not an expert in sql so the code might look a bit ubgly, but anyway, here it is.
// read data queries $rcmail_config['vacation_sql_read'] = array(
"SELECT " . "subject AS vacation_subject, " . "body AS vacation_message, " . "active AS vacation_enable FROM vacation " . "WHERE email=%username AND domain=%email_domain;",
"SELECT " . "REPLACE(" . "REPLACE(" . "goto," . "CONCAT(',',%email_local,'#'," . "%email_domain,'@','autoreply.',%email_domain)," . "''" . "), %email, ''" . ") " . "AS vacation_forwarder FROM alias " . "WHERE address=%username AND domain=%email_domain;"
);
// write data queries $rcmail_config['vacation_sql_write'] = array(
"DELETE FROM vacation WHERE email=%email AND domain=%email_domain;",
"DELETE from vacation_notification WHERE on_vacation=%email;",
"DELETE FROM alias WHERE address=%email AND domain=%email_domain;",
"INSERT INTO vacation (email,domain,subject,body,created,active) " . "VALUES (%email,%email_domain,%vacation_subject," . "%vacation_message,NOW(),%vacation_enable);",
"INSERT INTO alias (address,goto,domain,created,modified,active) " . "SELECT ". "%email," . "CONCAT(%email,',',%email_local,'#',%email_domain,'@'," . "'autoreply.',%email_domain,',',%vacation_forwarder)," . "%email_domain," . "NOW(),NOW(),1 " . "FROM mailbox WHERE username=%email AND domain=%email_domain AND " . "%vacation_enable=1;",
"INSERT INTO alias (address,goto,domain,created,modified,active) " . "SELECT %email,CONCAT(%email,',',%vacation_forwarder),%email_domain,NOW(),NOW(),1 " . "FROM mailbox WHERE username=%email AND domain=%email_domain AND " . "%vacation_enable=0;"
);
Thank you again for a nice plugin! You saved me from now on from the user harassments "going away" "returning" etc :) Serban.
you need to change somehow the disable vacation procedure. postfixadmin needs the alias table (to be more precise, postfixadmin needs to have in the alias table: address=user@domain.com goto=user@domain.com domain=domain.com active=1
at all times. when you disable vacation, you are deleting the alias entirely.