Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

ja_laravel_developer's avatar

Integrating Laravel with Microsoft Exchange

I am a developer working a project that requires me to use Microsoft Exchange as the solution for sending transactional emails. The client does not wish to integrate with Sendgrid or any other modern solutions. I have been search for tutorials but I cannot seem to find any on the integration process. If anybody has any experience with integrating Exchange in their laravel project could you please share the steps with me.

PLEASE!!!!

0 likes
3 replies
Talinon's avatar

@ja_laravel_developer

The first thing you need to determine is whether or not you'll be integrating with an on-premises Exchange Server, or working with cloud-based Office-365.

If you're dealing with on-prem, you'll probably want to look into the php-ews package.

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

If you're working with Office-365, then I would suggest working directly with Microsoft Graph's API. I just recently migrated a complex application that was heavily integrating with EWS over to Graph. It is Microsoft's latest platform for interacting with all kinds of services. You'll also find much more information, and better documentation.

After working with EWS for the better part of a decade, I can say that working with EWS is hell. If its within your control, I highly suggest working with the modern Graph API. If its not within your control, I would encourage the decision makers to migrate to Office-365 before you even attempt integration. It's just a matter of time until you'll basically be strong-armed into moving to Office-365 anyway. Also, Microsoft has already announced they are no longer adding new features to the EWS platform.

There is a PHP SDK for working with Graph. It's handy for converting responses from the API into flexible models that are easier to work with. Although, I find sometimes it's easier to directly work with the API using guzzle. That is a choice you'll need to make yourself. You can find more information on it here:

https://github.com/microsoftgraph/msgraph-sdk-php

If you're only looking for email integration, you might be able to find a Laravel mail driver that will do the majority of the work for you. In my case, I need much more integration than just email, but also contacts, calendar events, etc. If you foresee needing more integration support down the road, I would avoid using packages or wrappers and just make your own implementation. You'll thank yourself later when you're not hand-cuffed by someone else's package. Like I said, working with Graph is a much more pleasant experience.

You'll also need to handle OAuth2 token-based authentication, which is another layer of complexity, but it's really not that difficult to implement. Come Oct 2020, they are forcing EWS to use OAuth2 token based authentication - so regardless of which solution you decide, you'll be forced to deal with it either way.

1 like
ja_laravel_developer's avatar

@talinon Thank you very much for the response. The service is currently being provided by a third party vendor. I got the necessary credentials and I am testing the options you gave to me. I will let you know how it goes. Thank you very for taking the time to assist. THANK YOU

Please or to participate in this conversation.