pragmatiqu/mailer

从 Twig 模板发送 Laravel 邮件

1.0.0 2024-04-26 12:08 UTC

This package is auto-updated.

Last update: 2024-09-26 13:09:42 UTC


README

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

从 twig 模板发送模板化电子邮件。

支持我们

支持链接

安装

您可以通过 composer 安装此包

composer require pragmatiqu/mailer

您可以使用以下命令发布配置文件

php artisan vendor:publish --provider="Pragmatiqu\Mail\MailerServiceProvider" --tag="config"

这是已发布配置文件的内容

return [

  /*
  |--------------------------------------------------------------------------
  | Transport
  |--------------------------------------------------------------------------
  |
  | This option controls the default transport that is used to send any email
  | messages sent by your application. Alternative transports may be setup
  | and used as needed; default transport will be used if not other stated.
  |
  */
  'default' => env( 'TRANSPORT', 'sendmail' ),

  'transports' => [
    'sendmail' => 'sendmail://default',
    'smtp'     => env( 'SMTP_DNS', 'smtp://<user>:<password>@<host>:<port>' ),
    'mailtrap' => env( 'MAILTRAP_DNS', 'smtp://<user>:<password>@smtp.mailtrap.io:2525' )
  ],

  /*
  |--------------------------------------------------------------------------
  | Global "From" Address
  |--------------------------------------------------------------------------
  |
  | You may wish for all e-mails sent by your application to be sent from
  | the same address. Here, you may specify a name and address that is
  | used globally for all e-mails that are sent by your application.
  |
  */
  'from'       => [
    'address' => env( 'FROM_ADDRESS', 'test@test.at' ),
    'name'    => env( 'FROM_NAME', 'Testing' ),
  ],

  /*
   |--------------------------------------------------------------------------
   | Template engine configuration
   |--------------------------------------------------------------------------
   |
   */
  'templates'  => [

    'root' => resource_path( 'mails' ),

    'extension'   => 'twig',

    // Accepts all Twig environment configuration options
    // @see https://twig.symfony.com.cn/doc/3.x/api.html
    //
    'environment' => [

      // When set to true, the generated templates have a __toString() method
      // that you can use to display the generated nodes.
      // default: false
      'debug'            => env( 'APP_DEBUG', false ),

      // The charset used by the templates.
      // default: utf-8
      'charset'          => 'utf-8',

      // An absolute path where to store the compiled templates, or false to
      // disable caching. If null then the cache file path is used.
      // default: cache file storage path
      'cache'            => storage_path( 'mails/cache' ),

      // When developing with Twig, it's useful to recompile the template
      // whenever the source code changes. If you don't provide a value
      // for the auto_reload option, it will be determined automatically
      // based on the debug value.
      'auto_reload'      => true,

      // If set to false, Twig will silently ignore invalid variables
      // (variables and or attributes/methods that do not exist) and
      // replace them with a null value. When set to true, Twig throws an
      // exception instead.
      // default: false
      'strict_variables' => true,

      // If set to true, auto-escaping will be enabled by default for
      // all templates.
      // default: 'html'
      'autoescape'       => 'html',

      // A flag that indicates which optimizations to apply
      // (default to -1 -- all optimizations are enabled; set it to 0 to
      // disable)
      'optimizations'    => -1,
    ],
  ]
];

使用方法

// fill in the blanks…

测试

composer test

更新日志

请参阅 更新日志 了解最近更改的详细信息。

贡献

请参阅 贡献指南 了解详情。

安全漏洞

请查看 我们的安全策略 了解如何报告安全漏洞。

鸣谢

许可

MIT 许可证 (MIT)。请参阅 许可文件 了解更多信息。