#325 Delete alias error

open
nobody
7
21 hours ago
2014-07-18
Ben
No

Hi,

if I would like to delete an alias at postfixadmin I got the error message: this alias couldn´t be deleted, because it´s referencing to a mailbox (or something like that).

How can I delete an alias?

Best,

Ben

Discussion

  • Ben
    Ben
    2014-08-15

    Is there anybody, who can help me?

     
  • The same here.
    The problem is coming from the SQL query which is being used to select the alias:

    SELECT address,goto,coalesce(is_mailbox,0) as is_mailbox,CASE active WHEN '1' THEN '1' WHEN '0' THEN '0' END as active,CASE active WHEN '1' THEN 'YES' WHEN '0' THEN 'NO' END as _active,DATE_FORMAT(created, '%Y-%m-%d') AS created, created AS _created,DATE_FORMAT(modified, '%Y-%m-%d') AS modified, modified AS _modified,1 as editable FROM alias LEFT JOIN ( SELECT 1 as is_mailbox, username as mailbox_username FROM mailbox WHERE username IS NOT NULL ) AS mailbox ON __mailbox_username = address WHERE ( address='xxx@domain.com' ) AND domain IN ('domain.com') ORDER BY address;

    Look at the subquery:

    SELECT 1 as is_mailbox, username as mailbox_username FROM mailbox WHERE username IS NOT NULL

    So basically it is hardcoded to always return 1 for

    __is_mailbox

    and then this '1' is returned from

    coalesce(__is_mailbox,0)

    which leads us to the situation in which ALL aliases are seen as is_mailbox=1 which I think is the reason for not deleting the alias, because there is a check in the delete function in file AliasHandler.php

       if ($this->result['is_mailbox']) {
            $this->errormsg[] = Config::Lang('mailbox_alias_cant_be_deleted');
            return false;
        }
    
     
    Last edit: Deyan Chepishev 2014-08-15
  • Dave
    Dave
    2014-08-28

    Seems to be the same problem as in #313.

    Changing line 42 in AliasHandler.php from

    /select/ 'coalesce(__is_mailbox,0) as is_mailbox',

    to

    /select/ 'coalesce(__mailbox_username,0) as is_mailbox',

    solved the problem for me.

     
  • Ben
    Ben
    2014-08-28

    Yes, this solved it - thank you very much!

     
  • VladoP
    VladoP
    21 hours ago

    The patch worked for me too, but after upgrading to r1690 I'm getting this error again.