towoju5 / laravel-azure-mailer

为Laravel提供Microsoft Azure ACS集成。Azure Communication Services允许您轻松地将实时多媒体语音、视频和IP电话通信功能添加到您的应用程序中。通信服务电子邮件客户端库还允许您添加聊天和电子邮件功能。

v1.0 2024-07-22 09:56 UTC

This package is auto-updated.

Last update: 2024-09-22 10:25:06 UTC


README

为Symfony Mailer / Laravel提供Azure Communication Service集成。

要求

安装

首次使用Azure ECS?如果您还没有,请创建您的Azure账户

  1. 如果没有安装,请下载Composer

  2. 在项目目录下,通过命令行运行composer require jliglesias/laravel-azure-mailer

  3. 获取您的Azure CS访问密钥和服务端点。

配置

在[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')
        ],
    ]

  ?>

在[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
  

文档

通过将Azure Communication Service电子邮件集成添加到您的应用程序,构建强大的基于云的通信和客户参与体验。

  • Azure Communication Service文档:英文
  • 为Azure Communication Service Docs准备电子邮件通信资源:英文
  • 使用Laravel(10x)发送邮件:英文

示例

简单邮件发送

Mail::to($request->user())
    ->cc($moreUsers)
    ->bcc($evenMoreUsers)
    ->send(new OrderShipped($order));

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');

带有附件的邮件发送

$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);
            }

 });

如果您需要更多信息,请阅读Laravel(10x)文档:英文

最后更改

** 0.1.0-beta.1

  • 主版本。

** 0.1.1.-beta.1

  • 删除用于测试AJAX(JQUERY)事件调度和回调的文件夹和文件。

许可

MIT许可。版权(c)2024 - Juan Luis Iglesias 更多信息,请参阅LICENSE文件。