skip to Main Content

I’m trying to make this plugin for Roundcube that you can manage email aliases but I’m running into a little bit of a problem. When I call to fetch the email aliases it’s only showing the first one and ignoring any other ones that are available. For example, one of my email address has 4 aliases but it’s only showing the first alias and ignoring the rest.

This is the code that I have so far:

$plek_email = <<<EOF
<packet>
    <mail>
        <get_info>
            <filter>
          <site-id>$plesk_client_domain</site-id>
        </filter>
            <mailbox/>
            <aliases/>
        </get_info>
    </mail>
</packet>
EOF;
        
        $plesk_email_response = new SimpleXMLElement($plesk_client->request($plek_email));
        foreach ($plesk_email_response->mail->get_info->result->mailname as $mailname) {
            $plesk_client_email = $mailname->alias;
        }

2

Answers


  1. You’ll have to loop trough all the alias elements in the response XML output from the API.

    Like so:

        foreach($response->mail->get_info->result->mailname->alias as $alias) {
              print_r($alias);
        }
    
    Login or Signup to reply.
  2. FYI: There is a very useful Roundcube plugin called custom_from that lets you use parameters of your default identity combined with answering from email aliases in your main mailbox. That way you don’t have to mess with managing identities/aliases. You can even choose a completely virtual input (when your webhosting company allows you to).

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search