SSilence / php-imap-client

a easy solution for simple IMAP email access in php
MIT License
268 stars 138 forks source link

Problem with 'remote_system_name'=>$var_name (Can't open mailbox with such a name) #254

Open JewerlyBony opened 4 years ago

JewerlyBony commented 4 years ago

When I try to assign a value to 'remote_system_name' with a variable I get this error : Can't open mailbox with such a name (errflg=2) Here is my simple code :

     $imapserver= "imap.myserver.com";
     ImapClient::setConnectAdvanced();
     ImapClient::setConnectConfig([
          'flags' => [
               'service' => ImapConnect::SERVICE_IMAP,
               'encrypt' => ImapConnect::ENCRYPT_SSL,
               'validateCertificates' => ImapConnect::VALIDATE_CERT
          ],
          'mailbox' => [
               'remote_system_name' => $imapserver,
               'port' => 993
          ],
          'connect' => [
               'username' => $info[0],
               'password' => $info[1]
          ]
     ]);
     $imap = new ImapClient();

But the code works fine when I write imap server directly like this

          'mailbox' => [
               'remote_system_name' => 'imap.myserver.com',
               'port' => 993
          ],