Garethp/php-ews: 访问与同一个 MS exchange 用户关联的两个不同邮箱

Garethp/php-ews: access two different mailboxes associated to the same MS exchange user

库: Garethp/php-ews

MS Exchange 版本: 2016

我在同一个登录名下有两个邮箱。

mail1@example.com

mail2@example.com

授权:

$ews = API::fromUsernameAndPassword('example.com', 'mail1@example.com', 'some_pass');

我可以访问 mail1 中的所有文件夹,但不知道如何访问 mail2 内容。

有什么方法可以访问与同一 MS Exchange 用户关联的这两个不同邮箱?

GitHub 上也有类似的问题,但库不同 (jamesiarmes/php-ews): https://github.com/jamesiarmes/php-ews/issues/404

有什么想法吗?

有一个方法setPrimarySmtpEmailAddress。因此,登录到电子邮件帐户后,立即设置您要访问的电子邮件地址:

$ews = API::fromUsernameAndPassword(
'example.com', 
'mail1@example.com', 
'some_pass'
)->setPrimarySmtpEmailAddress('mail2@example.com')->getMailbox();

差不多就这些了。进一步的操作保持不变:获取文件夹、阅读电子邮件等