使用PHP访问Office356共享邮箱 [英] Access Office356 shared mailbox with PHP

查看:203
本文介绍了使用PHP访问Office356共享邮箱的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用PHP脚本来读取和解析发送到共享邮箱的错误日志.

I'm working on a PHP script to read and parse error logs sent to a shared mailbox.

我正在使用imap_open()进行连接.

I'm using imap_open() to connect.

如果我使用以下凭据连接到自己的邮箱,则效果很好

If I connect with the following credentials to my own mailbox, it works fine

server: {outlook.office365.com:993/imap/ssl}
username: myname@domain.com
password: mypas$word

但是,如果我想使用以下凭据连接到已保存的邮箱,则会收到错误消息

However, if I want to connect to the sared mailbox with the follwowing credentials, I get an error

server: {outlook.office365.com:993/imap/ssl}
username: myname@domain.com\shared-folder@domain.com
password: mypas$word

错误如下:User is authenticated but not connected. (errflg=2)

根据我的研究,这意味着我使用了错误的密码,但是由于该密码在连接到我自己的收件箱时可以正常工作,

According to my research that would mean I'm using the wrong password, but since it works when connecting to my own inbox, it can't be wrong

我100%确定我的帐户可以访问共享邮箱,可以通过Office 365网络界面通过我的帐户访问它

I am a 100% certain my account can access the shared mailbox, I can access it via my account through the Office 365 webinterface

更多细节:我的密码包含$符号,但这没关系.我在密码上使用单引号,而转义$符号无济于事,即使是我的个人邮箱也导致登录失败.

One more detail: my password includes a $ sign, but that shouldn't matter. I use single quotes on the password and escaping the $ sign doesn't help, it results in a failed login even for my personal mailbox.

推荐答案

尝试使用帐户别名

%USERUPN%/%SHAREDALIAS%例如:-

%USERUPN%/%SHAREDALIAS% for example:-

user@domain.com/sharedbox,其中"sharedbox"是共享邮箱的别名,而不是完整的电子邮件地址

user@domain.com/sharedbox where "sharedbox" is the alias of the shared mailbox instead of the full email address

我看到了一些报告,其中有些人使用正斜杠(/),有些人使用反斜杠(\)

I've seen different reports of some people using forward slash ( / ) and some using a backslash ( \ )

编辑

您是否使用邮箱别名?不要使用sharedbox@shareddomain.com

Are you using the mailbox alias? Do not use sharedbox@shareddomain.com

Exchange配置:

Exchange Configuration:

  USER EMAIL: user@maindomain.com
  PASSWORD: password



 SHARED MAILBOX: shared@anotherdomain.com      (could also be @domain.com, of course)
  SHARED MAILBOX ALIAS: shared-mailbox

注意:请确保始终与邮箱一起创建UNIQUE别名,因为它将创建用户[alias] @ maindomain.com.在这种情况下,shared-mailbox@maindomain.com

Note: Please make sure to create the UNIQUE alias always with the mailbox, because it creates the user [alias]@maindomain.com. In this case shared-mailbox@maindomain.com

IMAP配置的设置:

Settings for IMAP Configuration:

  EMAIL ADDRESS: shared@anotherdomain.com (shared mailbox)
  IMAP SERVER: outlook.office365.com
  SMTP SERVER: smtp.office365.com
  USERNAME: user@maindomain.com\shared-mailbox  (user\shared mailbox alias)
  PASSWORD: password (user's password)

这篇关于使用PHP访问Office356共享邮箱的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆