bonoweb/laravel-ews-driver

Adds Exchange Web Services Mail Support to Laravel.

v2.0 2021-03-19 12:15 UTC

This package is not auto-updated.

Last update: 2024-04-28 04:01:59 UTC


README

Forked From (https://github.com/adeboyed/laravel-ews-driver)

Packagist Version Packagist PHP Version Support

A Mail Driver with support for Exchange Web Services, using the original Laravel API. This library extends the original Laravel classes, so it uses exactly the same methods. This package requires a access to a EWS host.

This library uses the php-ews library to connect to the exchange web services host. Therefore requires the following dependencies:

  • Composer
  • PHP 5.4 or greater
  • cURL with NTLM support (7.30.0+ recommended)
  • Exchange 2007 or later

For more information, visit that repo

Install (Laravel)

Add the package to your composer.json and run composer update.

"require": {
    "bonoweb/laravel-ews-driver": "~2"
},

Add the Exchange service provider in config/app.php: (Laravel 5.5+ uses Package Auto-Discovery, so doesn't require you to manually add the ServiceProvider.)

'providers' => [
    Bonoweb\LaravelExchangeDriver\ExchangeAddedServiceProvider::class
];

Install (Lumen)

Add the package to your composer.json and run composer update.

"require": {
    "bonoweb/laravel-ews-driver": "~2"
},

or install with composer

$ composer require bonoweb/laravel-ews-driver

Add the exchange service provider in bootstrap/app.php

$app->configure('mail');
$app->configure('services');
$app->register(Bonoweb\LaravelExchangeDriver\ExchangeServiceProvider::class);

unset($app->availableBindings['mailer']);

Create mail config files. config/mail.php

<?php
return [
    'driver' => env('MAIL_DRIVER', 'exchange'),
];

Configure

.env

MAIL_DRIVER=exchange
MAIL_HOST=webmail.example.com
MAIL_USERNAME=examplemail
MAIL_PASSWORD=examplepassword
MAIL_MESSAGE_DISPOSITION_TYPE=SaveOnly|SendAndSaveCopy|SendOnly
MAIL_CA_FILE="/path/to/cacert.pem"
MAIL_CLIENT_VERSION="Exchange2010"

config/mail.php (In using lumen, this requires creating config directory and file, see more here)

    'mailers' => [
        'exchange' => [
            'transport' => 'exchange',
            'host' => env('MAIL_HOST'),
            'username' => env('MAIL_USERNAME'),
            'password' => env('MAIL_PASSWORD'),
            'messageDispositionType' => env('MAIL_MESSAGE_DISPOSITION_TYPE') // Optional, default: SendAndSaveCopy
            'clientVersion' => env('MAIL_CLIENT_VERSION'), //Optional
            'caFile' => env('MAIL_CA_FILE'), // Optional, if you want to set a specific SSL CA 
        ],
    ],

For more information on the Message Disposition Type, view more here

##Attachments

If you have problems sending attachments, try setting in the .env MAIL_CLIENT_VERSION="Exchange2010_SP2" See Here