towoju5 / laravel-azure-mailer
Provides Microsoft Azure ACS integration for laravel. Azure Communication Services allows you to easily add real-time multimedia voice, video, and telephony-over-IP communications features to your applications. The Communication Services Email client libraries also allow you to add chat and EMAIL fu
This package is auto-updated.
Last update: 2024-11-30 19:18:53 UTC
README
Provides Azure Communication Service integration for Symfony Mailer / Laravel.
Requirements
- PHP 8.2 or higher.
- Laravel 10.x or higher.
- Azure account, Azure CS Access Key and Service Endpoint.
Installation
First time using Azure ECS? Create your Azure account, if you don’t have one already.
-
Download Composer if not already installed
-
On your project directory run on the command line
composer require jliglesias/laravel-azure-mailer
-
Get your Azure CS Access Key and Service Endpoint.
Configuration
Add entry to [root-of-laravel]/config/mail.php:
<?php ... 'mailers' => [ //...other drivers 'azure' => [ 'transport' => 'azure', 'resource_name' => env('AZURE_MAIL_RESOURCE_NAME'), 'endpoint' => env('AZURE_MAIL_ENDPOINT', 'https://my-acs-resource-name.communication.azure.com'), 'access_key' => env('AZURE_MAIL_KEY'), 'api_version' => env('AZURE_MAIL_API_VERSION', '2023-03-31'), 'disable_user_tracking' => env('AZURE_MAIL_DISABLE_TRACKING', false), 'sender_address' => env('AZURE_MAIL_SENDER_ADDRES', 'donotreply@azure.com') ], ] ?>
Add entry to [root-of-laravel]/.env:
#...other entries
# Mail service entries...
MAIL_MAILER=azure
#=================================================
# Azure Service entries
#=================================================
AZURE_MAIL_RESOURCE_NAME=my-acs-resource-name
AZURE_MAIL_KEY=AzureAccessToken
AZURE_MAIL_SENDER_ADDRES
Documentation
Build powerful, cloud-based communication and customer engagement experiences by adding email integration with Azure Communication Service to your apps.
- Azure Communication Service Docs: English
- Prepare Email Communication resource for Azure Communication Service Docs: English
- Sending mail with Laravel (10x): English
Examples
Simple mail sending:
Mail::to($request->user())
->cc($moreUsers)
->bcc($evenMoreUsers)
->send(new OrderShipped($order));
or
Mail::to([new Address('user.name@domain.com', 'My User Name'), ...])
->cc([new Address('user.name@domain.com', 'My User Name'), ...])
->bcc([new Address('user.name@domain.com', 'My User Name'), ...])
->send('my.view');
Sending mail with attachments:
$data = [
to => [new Address('user.name@domain.com', 'My User Name'), ...],
subject => 'Subject'
];
$files = [
public_path('files/160031367318.pdf'),
public_path('files/1599882252.png'),
];
Mail::send('my.view', $data, function($message)use($data, $files) {
$message->to($data["to"])
->subject($data["subject"]);
foreach ($files as $file){
$message->attach($file);
}
});
If you need more information, read the Laravel (10x) documentation: English
Last change
** 0.1.0-beta.1
- Main release.
- Remove folders and files for testing event dispatch and callbacks using AJAX (JQUERY).
License
MIT license. Copyright (c) 2024 - Juan Luis Iglesias For more information, see the LICENSE file.