使用 PHP 访问 Exchange 的最佳方式?

发布于 2024-07-03 23:53:01 字数 562 浏览 7 评论 0原文

我正在用 PHP 编写一个 CMS 应用程序,要求之一是它必须能够与客户的 Exchange 服务器连接。 我之前已经多次编写过此功能,并且一直使用 WebDAV 来执行此操作,但是现在我正在远离这个。

我将在 Windows Server 2008 上的 IIS 或 Apache(无偏好)上运行该网站。我需要做的一些事情包括将联系人添加到给定用户的地址簿、作为给定用户发送电子邮件以及运行有关联系人的报告。用户。

所有这些都可以通过 WebDAV 轻松完成,但如果有更好的方法不需要任何可能很快就会被弃用的功能。

有任何想法吗?

更新:

贾斯汀,我喜欢使用 com 对象的想法,我只担心维护第三个产品以使一切正常工作...

约翰,我可以用 C# 编写一个 Web 服务来与这些功能交互并使用我的 PHP 访问它应用程序,但它也有点偏僻。

到目前为止,我并不是 100% 相信这两者都比 WebDAV 更好……

谁能告诉我我哪里傻了?

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 WebDAV to do it, but now I'm leaning away from that.

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.

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.

Any ideas?

Update:

Justin, I love the idea of using com objects, I just worry about maintaining a 3rd product to make everything work...

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.

So far, I'm not 100% convinced that either of these is better than WebDAV...

Can anyone show me where I'm being silly?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(9

吝吻 2024-07-10 23:53:01

截至 2020 年更新:
十多年来,这个问题和事情都在发生变化。 Microsft 现在有 Rest API 可让您轻松访问此数据。


原始答案

我没有使用 PHP 来做到这一点,但有使用 C# 来实现同样的事情的经验。

Outlook API 是一种自动化 Outlook 的方法,而不是直接连接到 Exchange。 我之前在 C# 应用程序中采用过这种方法,它确实有效,但可能存在错误。

如果您希望直接连接到 Exchange 服务器,则需要研究扩展 MAPI。

过去我使用过这个包装器 MAPIEx:扩展 MAPI 包装器

这是一个 C# 项目,但我相信您可以在 PHP5 Windows 服务器上使用一些 .NET 代码。 或者,它有一个您可以使用的 C++ 核心 DLL。 我发现它非常好,并且有一些很好的示例应用程序。


对于延迟,我们深表歉意,目前还没有方法来跟踪帖子。

我确实同意在您的应用程序中添加更多层并依赖第 3 方代码可能会很可怕(这是理所当然的。)

今天我读了另一篇 有趣的帖子,标记为 MAPI,涉及不同的主题。 但这里的关键是它已链接到 这篇重要的 MS 文章。 到目前为止,我一直没有意识到使用托管代码与 MAPI 接口的问题,尽管组件中的 C++ 代码应该不受此错误的影响,因为它是非托管的。

此博客文章还建议了连接到 MAPI/Exchange 服务器的其他方法。 在这种情况下,由于这些新事实 https://www.php.net/imap 可能是按照其他用户的建议回答。

Update as of 2020:
Over a decade since this question and things have moved on. Microsft now has a Rest API that will allow you to easily access this data.


Original Answer

I have not used PHP to do this but have experience in using C# to achieve the same thing.

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.

If you wish to connect directly to the Exchange server you will need to research extended MAPI.

In the past I used this 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.


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.)

Today I read another interesting post tagged 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.

This blog entry also suggests other ways to connect to MAPI/Exchange server. In this case due to these new facts https://www.php.net/imap may be the answer as suggested by the other user.

无远思近则忧 2024-07-10 23:53:01

您的客户使用 Exchange 2007 吗? 如果是这样,我会看看 Exchange Web Services< /a>. 如果没有,尽管可能很棘手,但我认为 WebDAV 是您最好的选择。

就我个人而言,我不喜欢使用 Outlook.Application COM 对象路由,因为它的安全提示(“应用程序正在尝试访问您的联系人。允许这样做吗?”等)可能会导致服务器出现问题。 我还认为使用 Outlook 完成类似模拟的任务(例如作为给定用户发送邮件)会很困难。

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.

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.

何其悲哀 2024-07-10 23:53:01

我发布了一个 MIT 许可的开源库,它允许您使用 Exchange Web 服务在 PHP 中执行一些基本操作。

Exchange Web Services for PHP

我只在 Linux 上测试过它,但我不知道我看不出有什么理由说明它不能在 Windows 安装的 PHP 上运行。

I have released an open-source MIT licensed library that allows you to do some basic operations in PHP using Exchange Web Services.

Exchange Web Services for 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.

可是我不能没有你 2024-07-10 23:53:01

我对 Dmitry Streblechenko 的兑换数据对象库的推荐度不够高。 它是一个 COM 组件,为扩展 MAPI 提供了健全的 API,并且使用起来很有趣。 Exchange API 的目标从一个版本转移到下一个版本:“使用 M: 驱动器! 不,使用 WebDAV! 不,使用 ExOLEDB!...不,使用 Web 服务!” 唯一不变的是旧的 MAPI。

I can't recommend Dmitry Streblechenko's Redemption Data Objects library 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.

养猫人 2024-07-10 23:53:01

我不是 PHP 开发人员,但 Google 说 PHP 5+ 可以实例化 COM 组件。 如果您可以在盒子上安装 Outlook,您可以围绕 COM 组件编写 PHP Web 服务来处理您需要的请求。

$outlook = COM("Outlook.Application")

Outlook API 参考

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.

$outlook = COM("Outlook.Application")

Outlook API referance

我为君王 2024-07-10 23:53:01

我建议使用 "PHP Exchange Web Services" 或简短的 php-ews。

wiki 下有大量文档,对我有帮助很多。

I would recommend using "PHP Exchange Web Services" or short php-ews.

Fair amount of documentation under the wiki, helped me a lot.

十六岁半 2024-07-10 23:53:01

这个 Zarafa PHP MAPI 扩展看起来可以工作。

This Zarafa PHP MAPI extension looks like it could work.

城歌 2024-07-10 23:53:01

我会研究 IMAP

IMAP、POP3 和 NNTP

I would look into IMAP

IMAP, POP3 and NNTP

筱果果 2024-07-10 23:53:01

https://github.com/Garethp/php-ews

最后更新是在 3 个月前,所以它被维护

https://github.com/Garethp/php-ews

It was last updated 3 months ago so it is maintained

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文