resohead/laravel-test-mail 问题修复 & 功能扩展

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

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

resohead/laravel-test-mail

最新稳定版本:v2.0.0

Composer 安装命令:

composer require resohead/laravel-test-mail

包简介

Quickly send test emails using commands in Laravel applications

README 文档

README

Latest Version on Packagist Build Status Code Coverage Quality Score Maintainability Total Downloads

A simple package to send test emails from artisan commands in Laravel applications. Ideal for checking mail and queue configurations without any setup.

Installation

You can install the package via composer:

composer require resohead/laravel-test-mail

The package will automatically register itself.

Optionally publish the config file to enable presets:

php artisan vendor:publish --provider="Resohead\LaravelTestMail\LaravelTestMailServiceProvider" --tag="config"

Basic Usage

To send a test email run the following artisan command:

php artisan mail:test

By default this will:

  • send to the 'from' address defined in your mail config,
  • use your default mail driver,
  • synchronous processing

Alternatively you have four other options in the command signature:

  • set the email address,
  • change the mail driver,
  • enable for queuing (and set the queue name)
  • change the queue connection
  • select a preset

Changing the mail driver and running through a queue might require the queue worker to be started/reset.

Command Line Options

Send to specified email

php artisan mail:test name@example.com

Send to specified email on default queue

php artisan mail:test name@example.com --queue

Send via log driver

php artisan mail:test --driver=log

Send to the 'emails' queue on default connection

php artisan mail:test --stack=emails

There is no need to set the --queue flag when using the stack argument

Send using 'sqs' queue connection

php artisan mail:test --connection=sqs

There is no need to set the --queue flag when using the connection argument

Send using the SMTP driver via the 'emails' queue on the 'redis' connection

php artisan mail:test name@example.com --driver=smtp --connection=redis --stack=emails

Queues

You might need to start the your queue if using the connection option, for example

php artisan queue:work sqs --queue:emails

Presets

You can also configure presets to group command line options. The values defined in each preset will be merged with the command line values and your default mail and queue configuration.

Example config\mail-test.php

'presets' => [

        'example1' => [
            'recipient' => 'preset1@example.com',
            'queue' => true
        ],

        'example2' => [
            'driver' => 'log',
            'stack' => 'emails'
        ],

        'example3' => [
            'recipient' => env('EMAIL_TO', 'preset3@example.com'),
            'driver' => 'smtp',
            'connection' => 'redis',
            'stack' => 'notifications'
        ],

    ]

Preset: Example 1

Set a specific email address and use default queue:

php artisan mail:test --preset=example1

// php artisan mail:test preset1@example.com --queue

Preset: Example 2

Use the log mail driver and emails queue

php artisan mail:test --preset=example2

// php artisan mail:test --driver=log --stack=emails

Preset: Example 3

Use the log mail driver and emails queue

php artisan mail:test --preset=example3

// php artisan mail:test preset3@example.com --driver=smtp --connection=redis --stack=notifications

Alternatives

This is a simple package designed to quickly trigger an email to check your configuration.

If you want to check what an email looks like in the browser use the Laravel documentation to render mailables (available since Laravel 5.5).

If you need a package to send a mailable using fake data try using Spatie's laravel-mailable-test package.

Testing

composer test

Changelog

Please see CHANGELOG for more information what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Credits

License

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-03-23