承接 seinoxygen/laravel-elastic-email 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

seinoxygen/laravel-elastic-email

最新稳定版本:v1.0.5

Composer 安装命令:

composer require seinoxygen/laravel-elastic-email

包简介

A Laravel wrapper for Elastic Email

README 文档

README

Donate Packagist Downloads GitHub CodeFactor Grade

A Laravel wrapper for sending emails via Elastic Email service and API capabilities that allows you to check the status of every email sent. It provides a basic email log table to store all outbound emails where you can link to a model.

Installation

Add Laravel Elastic Email as a dependency using the composer CLI:

composer require seinoxygen/laravel-elastic-email

Mail Service Usage

This package works exactly like Laravel's native mailers. Refer to Laravel's Mail documentation.

Add the following to your config/services.php and add the correct values to your .env file

'elastic_email' => [
	'key' => env('ELASTIC_KEY'),
	'account' => env('ELASTIC_ACCOUNT')
]

Add the following to your config/mail.php

'elastic_email' => [
	'transport' => 'elasticemail'
]

Next, in config/app.php, comment out Laravel's default MailServiceProvider. If using < Laravel 5.5, add the MailServiceProvider and ApiServiceProvider to the providers array

'providers' => [
    ...
    SeinOxygen\ElasticEmail\MailServiceProvider::class,
    SeinOxygen\ElasticEmail\ApiServiceProvider::class,
    ...
],

Next, in config/app.php, add the ElasticEmail to the aliases array

'aliases' => [
    ...
    'ElasticEmail' => SeinOxygen\ElasticEmail\Facades\ElasticEmail::class,
    ...
],

Finally switch your default mail provider to elastic email in your .env file by setting MAIL_DRIVER=elastic_email

Outbound Email Tracking

To keep track of all emails sent by the driver you'll need to publish the migrations and the configuration files:

php artisan vendor:publish --provider="SeinOxygen\ElasticEmail\ApiServiceProvider" --tag="migrations"
php artisan migrate
php artisan vendor:publish --provider="SeinOxygen\ElasticEmail\ApiServiceProvider" --tag="config"

By default all outgoing emails will be stored with the Elastic Email message_id and transaction_id.

Check config/elasticemail.php for more options.

Linking Outgoing Emails To Your Models

In your mailable be sure to set the with array the following way.

public function build()
{
    // You can set ad many models you want to relate with the outgoing email
    $models = [
        [$yourmodel->id, get_class($yourmodel)],
    ];

    return $this
        ->subject("My Subject")
        ->view('my-view')
        ->with([
            'models' => $models
        ]);
}

Sorry if it looks ugly. I haven't found a better way to do this...yet.

Capturing Webhook Events

You will need to set a webhook in Elastic Email service pointing to yourappurl.com/webhook/elasticemail

There is an event being fired when data is sent to the webhook url.

<?php

namespace app\Listeners;

use SeinOxygen\ElasticEmail\Events\WebhookCallReceived;

class WebhookCallListerner
{
    public function handle(WebhookCallReceived $event)
    {
        $request = $event->request;
    }
}

Api Usage

For documentation visit https://api.elasticemail.com/public/help

    //For contact
    ElasticEmail::Contact()

    //For emails
    ElasticEmail::Email()

Credits

This package is based on ZanySoft

License

The MIT License (MIT). Please see License File for more information.

统计信息

  • 总下载量: 180
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-10-20

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固