tahsingokalp / laravel-ews-driver
Adds Exchange Web Services Mail Support to Laravel.
Package info
github.com/TahsinGokalp/laravel-ews-driver
pkg:composer/tahsingokalp/laravel-ews-driver
Requires
- php: >=8.1
- illuminate/mail: ^10.0|^11.0|^12.0|^13.0
- illuminate/support: ^10.0|^11.0|^12.0|^13.0
- php-ews/php-ews: ^1.0
- symfony/mailer: ^6.2|^7.0|^8.0
- symfony/mime: ^6.2|^7.0|^8.0
Requires (Dev)
- orchestra/testbench: ^8.0|^9.0|^10.0|^11.0
- phpunit/phpunit: ^10.5|^11.5|^12.0
Suggests
None
Provides
None
Conflicts
None
Replaces
None
This package is auto-updated.
Last update: 2026-10-10 20:41:44 UTC
README
A Laravel mail transport that sends mail through Exchange Web Services (EWS). Mailables, notifications and the Mail facade work exactly as with any other Laravel mailer.
This library uses the php-ews library to connect to the EWS host and requires:
- PHP 8.1 or greater (Laravel 13 requires PHP 8.3, Symfony 8 requires PHP 8.4)
- Laravel 10, 11, 12 or 13
- The PHP
soapandcurlextensions, with cURL NTLM support (7.30.0+ recommended) - Exchange 2007 or later
Warning
Exchange Online (Microsoft 365) is not supported. This driver authenticates with a username and password, which Exchange Online no longer accepts for EWS, and Microsoft is retiring EWS in Exchange Online: blocking started on 1 October 2026 and access is removed permanently on 1 April 2027. On-premises Exchange Server is not affected. For Exchange Online, use a Microsoft Graph based mailer instead.
Install
composer require tahsingokalp/laravel-ews-driver
The service provider is registered automatically through package auto-discovery.
Configure
Add an exchange mailer to config/mail.php:
'mailers' => [ // ... 'exchange' => [ 'transport' => 'exchange', 'host' => env('MAIL_HOST'), 'username' => env('MAIL_USERNAME'), 'password' => env('MAIL_PASSWORD'), 'version' => env('MAIL_VERSION'), 'messageDispositionType' => env('MAIL_MESSAGE_DISPOSITION_TYPE'), 'verifySsl' => env('MAIL_VERIFY_SSL', false), ], ],
and set it up in .env:
MAIL_MAILER=exchange
MAIL_HOST=webmail.example.com
MAIL_USERNAME=examplemail
MAIL_PASSWORD=examplepassword
MAIL_VERSION=Exchange2016
MAIL_MESSAGE_DISPOSITION_TYPE=SendAndSaveCopy
MAIL_VERIFY_SSL=false
MAIL_FROM_ADDRESS=examplemail@example.com
| Key | Required | Default | Description |
|---|---|---|---|
host |
yes | EWS host. | |
username |
yes | EWS username. | |
password |
yes | EWS password. | |
version |
no | Exchange2013 |
One of the jamesiarmes\PhpEws\Client::VERSION_* values, e.g. Exchange2010, Exchange2013, Exchange2016. |
messageDispositionType |
no | SendAndSaveCopy |
SendAndSaveCopy (send and keep a copy in Sent Items), SendOnly or SaveOnly (save as a draft without sending). More information. |
verifySsl |
no | false |
Verify the EWS host's SSL certificate. Enable it whenever the host has a valid certificate. |
A missing required value or an unknown messageDispositionType throws a TahsinGokalp\LaravelEwsDriver\Exceptions\EwsException when the mailer is resolved.
Sender
The message's own from address is used as the sender: the mailable's from, or Laravel's global mail.from.address. The EWS account must have "Send As" permission for any address other than its own mailbox.
Failover
Exchange errors are thrown as EwsException, which is a Symfony TransportException, so the driver works with Laravel's failover and roundrobin mailers:
'failover' => [ 'transport' => 'failover', 'mailers' => ['exchange', 'smtp'], ],
Supported message features
| Message feature | Sent to Exchange as |
|---|---|
| To, Cc, Bcc (and other envelope recipients) | ToRecipients, CcRecipients, BccRecipients |
| HTML or plain text body | Body (HTML is preferred when both are set) |
| Attachments | FileAttachment |
Embedded images ($message->embed()) |
Inline FileAttachment with its Content-ID |
| Reply-To | ReplyTo |
Priority (X-Priority) |
Importance |
Read / delivery receipt (Disposition-Notification-To, Return-Receipt-To) |
IsReadReceiptRequested, IsDeliveryReceiptRequested |
In-Reply-To, References |
Threading fields |
Message-ID |
PidTagInternetMessageId |
Other headers (e.g. X-*, List-Unsubscribe) |
Internet message headers |
Testing
composer test