使用 PHP 访问 Exchange 的最佳方式?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/588/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Best way to access Exchange using PHP?
提问by Bruce the Hoon
I'm writing a CMS application in PHP and one of the requirements is that it must be able to interface with the customer's Exchange server. I've written up this functionality a few times before and have always used WebDAVto do it, but now I'm leaning away from that.
我正在用 PHP 编写 CMS 应用程序,其中一项要求是它必须能够与客户的 Exchange 服务器进行交互。我之前已经写过几次这个功能并且一直使用WebDAV来完成它,但现在我倾向于远离它。
I will be running the site on IIS OR Apache (no preference) on Windows server 2008. A few things I would need to do include adding contacts to a given user's address book, sending emails as a given user and running reports on contacts for a user.
我将在 Windows server 2008 上的 IIS 或 Apache(无偏好)上运行该站点。我需要做的一些事情包括将联系人添加到给定用户的地址簿,以给定用户的身份发送电子邮件以及运行联系人报告用户。
All of this is pretty easy to do with WebDAV, but if there is a better way that doesn't require any functionality that is likely to be deprecated any time soon.
所有这些都可以通过 WebDAV 轻松完成,但如果有更好的方法不需要任何可能很快就会被弃用的功能。
Any ideas?
有任何想法吗?
Update:
更新:
Justin, I love the idea of using com objects, I just worry about maintaining a 3rd product to make everything work...
贾斯汀,我喜欢使用 com 对象的想法,我只是担心维护第三个产品以使一切正常......
John, I can write a web service in C# to interface with for these functions and access it with my PHP app, but it's also a little bit out of the way.
John,我可以用 C# 编写一个 Web 服务来与这些函数进行交互,并使用我的 PHP 应用程序访问它,但这也有点麻烦。
So far, I'm not 100% convinced that either of these is better than WebDAV...
到目前为止,我不是 100% 相信这两者都比 WebDAV 更好......
Can anyone show me where I'm being silly?
谁能告诉我我哪里傻了?
采纳答案by John
I have not used PHP to do this but have experience in using C# to achieve the same thing.
我没有使用 PHP 来做到这一点,但在使用 C# 来实现同样的事情方面有经验。
The Outlook API is a way of automating Outlook rather than connecting to Exchange directly. I have previously taken this approach in a C# application and it does work although can be buggy.
Outlook API 是一种自动化 Outlook 的方式,而不是直接连接到 Exchange。我以前在 C# 应用程序中采用了这种方法,它确实有效,但可能有问题。
If you wish to connect directly to the Exchange server you will need to research extended MAPI.
如果您希望直接连接到 Exchange 服务器,则需要研究扩展 MAPI。
In the past I used this wrapper MAPIEx: Extended MAPI Wrapper.
过去我使用了这个包装器MAPIEx: Extended MAPI Wrapper。
It is a C# project but I believe you can use some .NET code on a PHP5 Windows server. Alternatively it has a C++ core DLL that you may be a able to use. I have found it to be very good and there are some good example applications.
这是一个 C# 项目,但我相信您可以在 PHP5 Windows 服务器上使用一些 .NET 代码。或者,它有一个您可以使用的 C++ 核心 DLL。我发现它非常好,并且有一些很好的示例应用程序。
Update:
更新:
Sorry for the delay no current way to keep track of posts yet.
抱歉,目前还没有跟踪帖子的方法。
I do agree adding more layer on to your application and relying on 3rd party code can be scary (and rightfully so.)
我确实同意为您的应用程序添加更多层,并且依赖 3rd 方代码可能会很可怕(这是理所当然的。)
Today I read another interesting posttagged up as MAPI that is on a different subject. The key thing here though is that it has linked to this important MS article. I have been unaware of the issues until now on using managed code to interface to MAPI although the C++ code in the component should be unaffected by this error as it is unmanaged.
今天,我阅读了另一篇标记为 MAPI 的有趣帖子,该帖子涉及不同的主题。不过这里的关键是它已链接到这篇重要的 MS 文章。到目前为止,我一直没有意识到使用托管代码与 MAPI 接口的问题,尽管组件中的 C++ 代码应该不受此错误的影响,因为它是非托管的。
This blog entry also suggests other ways to connect to MAPI/Exchange server. In this case due to these new facts http://us3.php.net/imapmay be the answer as suggested by the other user.
此博客条目还建议了连接到 MAPI/Exchange 服务器的其他方法。在这种情况下,由于这些新事实http://us3.php.net/imap可能是其他用户建议的答案。
回答by Mike Powell
Is your customer using Exchange 2007? If so, I'd have a look at Exchange Web Services. If not, as hairy as it can be, I think WebDAV is your best bet.
您的客户是否使用 Exchange 2007?如果是这样,我会看看Exchange Web Services。如果没有,尽管毛茸茸的,我认为 WebDAV 是您最好的选择。
Personally I don't like using the Outlook.Application COM object route, as its security prompts ("An application is attempting to access your contacts. Allow this?", etc.) can cause problems on a server. I also think it would be difficult to accomplish your impersonation-like tasks using Outlook, such as sending mail as a given user.
我个人不喜欢使用 Outlook.Application COM 对象路由,因为它的安全提示(“应用程序正在尝试访问您的联系人。允许吗?”等)可能会导致服务器出现问题。我还认为使用 Outlook 完成类似模拟的任务会很困难,例如以给定用户的身份发送邮件。
回答by Riley Dutton
I have released an open-source MIT licensed library that allows you to do some basic operations in PHP using Exchange Web Services.
我发布了一个开源的 MIT 许可库,它允许您使用 Exchange Web 服务在 PHP 中执行一些基本操作。
I have only tested it on Linux but I don't see any reason why it wouldn't work on a Windows installation of PHP as well.
我只在 Linux 上测试过它,但我看不出它在 Windows 安装的 PHP 上也不起作用的任何原因。
回答by Duncan Smart
I can't recommend Dmitry Streblechenko's Redemption Data Objectslibrary highly enough. It's a COM component that provides a sane API to Extended MAPI and is a joy to use. The Exchange API goalposts move from one release to the next: “Use the M: drive! No, use WebDAV! No, use ExOLEDB!… No, use Web Services!” with the only constant being good old MAPI.
我不能高度推荐 Dmitry Streblechenko 的Redemption Data Objects库。它是一个 COM 组件,为扩展 MAPI 提供了一个健全的 API,使用起来很愉快。Exchange API 目标从一个版本转移到下一个版本:“使用 M: 驱动器!不,使用 WebDAV!不,使用 ExOLEDB!……不,使用 Web 服务!” 唯一不变的是旧的 MAPI。
回答by Justin Walgran
I'm not a PHP dev but Google says that PHP 5+ can instantiate COM components. If you can install Outlook on a box you could write a PHP web service around the COM component to handle the requests you need.
我不是 PHP 开发人员,但 Google 说 PHP 5+ 可以实例化 COM 组件。如果您可以在盒子上安装 Outlook,您就可以围绕 COM 组件编写 PHP Web 服务来处理您需要的请求。
$outlook = COM("Outlook.Application")
回答by Valentin Despa
I would recommend using "PHP Exchange Web Services"or short php-ews.
我建议使用“ PHP Exchange Web Services”或简短的php-ews。
Fair amount of documentation under the wiki, helped me a lot.
wiki下的大量文档对我帮助很大。
回答by Scott Szretter
This Zarafa PHP MAPIextension looks like it could work.
这个Zarafa PHP MAPI扩展看起来可以工作。
回答by Tim Boland
回答by Justin Levene
https://github.com/Garethp/php-ews
https://github.com/Garethp/php-ews
It was last updated 3 months ago so it is maintained
它是在 3 个月前最后更新的,所以它被维护了

