hashemi/too-mailable 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

hashemi/too-mailable

Composer 安装命令:

composer require hashemi/too-mailable

包简介

A Laravel based package for changing `Mail` transport and it's credentials from application layer in runtime. Simple and easy abstraction `Mailable` layer will be provided with this package. Currently this package support only SMTP

README 文档

README

A Laravel based package for changing Mail transport and it's credentials from application layer in runtime. Simple and easy abstraction Mailable layer will be provided with this package. Currently this package support only SMTP.

Installation

You can start it from composer. Go to your terminal and run this command from your project root directory.

composer require hashemi/laravel-too-mailable
  • If you're using Laravel, then Laravel will automatically discover the package. In case it doesn't discover the package then add the following provider in your config/app.php's providers array.
Hashemi\TooMailable\TooMailableServiceProvider::class

Usage

This package will be provide TooMailable abstract class and you need to use your mail class. This abstract class has two abstract method.

  • transport(): string|EsmtpTransport This method will be return package supported transport by string or custom transport class which will be EsmtpTransport inherited.

  • credentials(): array This method will be return necessary credentials of current transport.

Example:

use Hashemi\TooMailable\TooMailable;

class SendVerificatioMail extends TooMailable
{
    //... 

    public function transport()
    {
        return 'amazon';
    }

    public function credentials()
    {
        return [
            'username' => 'my-user',
            'password' => 'password-123',
            'region' => 'us-east-2'
        ];
    }
}

This package is also contain a config where each built-in transport class is configured. If anyone needs to override that transport they can easily do it by publish config from vendor. Config file will be stored in config/too-mailable.php on your application.

Example:

use Hashemi\TooMailable\Transports\{
    Amazon, Google, Mailchimp, Mailgun, Mailjet, 
    OhMySmtp, Postmark, Sendgrid, SendInBlue
};

return [
    'transports' => [
        'amazon' => Amazon::class,
        'google' => Google::class,
        'mailchimp' => Mailchimp::class,
        'mailgun' => Mailgun::class,
        'mailjet' => Mailjet::class,
        'postmark' => Postmark::class,
        'sendgrid' => Sendgrid::class,
        'sendinblue' => SendInBlue::class,
        'oh-my-smtp' => OhMySmtp::class,
    ],
];

So if you want to change exists transport then,

return [
    'transports' => [
        //...
        'amazon' => MyNewAmazonTransport::class,
    ],
];

Or, if you want to add new transport then,

return [
    'transports' => [
        //...
        'converkit' => MyNewConvertKit::class
    ],
];

But MyNewConvertKit class should be implements Hashemi\TooMailable\Interfaces\TransportInterface interface. Credentials will be passed through __construct function of MyNewConvertKit class.

Contributing

Pull requests are welcome. For any changes, please open an issue first to discuss what you would like to change.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-11-02

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固