onix-systems-php / hyperf-mailer
用于发送电子邮件的扩展
v1.3.0
2024-02-05 09:06 UTC
Requires
- php: >=8.1
- ext-json: *
- ext-swoole: >=4.5
- aws/aws-sdk-php: ^3.297
- hyperf/async-queue: ^3.1
- hyperf/command: ^3.1
- hyperf/config: ^3.1
- hyperf/devtool: ^3.1
- hyperf/di: ^3.1
- hyperf/event: ^3.1
- hyperf/filesystem: ^3.1
- hyperf/logger: ^3.1
- hyperf/translation: ^3.1
- hyperf/view: ^3.1
- league/flysystem: ^2.0|^3.0
- onix-systems-php/hyperf-core: >=1.2.0
- symfony/http-client: ^7.0
- symfony/mailer: ^6.0
- tijsverkoyen/css-to-inline-styles: ^2.2
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.0
- mockery/mockery: ^1.0
- phpstan/phpstan: ^1.0
- phpunit/phpunit: ^10.5
- swoole/ide-helper: ^4.5|^5.0
Suggests
- symfony/amazon-mailer: Amazon SES transport.
- symfony/infobip-mailer: Infobip transport.
- symfony/mailchimp-mailer: MailChimp Mandrill transport.
- symfony/mailgun-mailer: Mailgun transport.
- symfony/mailjet-mailer: Mailjet transport.
- symfony/mailpace-mailer: MailPace transport.
- symfony/postmark-mailer: Postmark transport.
- symfony/sendgrid-mailer: SendGrid transport.
- symfony/sendinblue-mailer: Sendinblue transport.
README
为symfony/mailer包提供hyperf包装器。
包括以下类
- 命令
- GenMailCommand;
- 契约
- HasLocalePreference;
- HasMailAddress;
- ShouldQueue;
- 事件
- MailMessageSending;
- MailMessageSent.
- 服务
- EmailService.
- Mail;
- Mailable.
安装
composer require onix-systems-php/hyperf-mailer
发布配置
php bin/hyperf.php vendor:publish onix-systems-php/hyperf-mailer
代码示例
<?php declare(strict_types=1); namespace App\Mail\Users; use OnixSystemsPHP\HyperfMailer\Contract\ShouldQueue; use OnixSystemsPHP\HyperfMailer\Mailable; class TestEmail extends Mailable implements ShouldQueue { public function __construct(private string $name) { } public function build(): void { $this ->subject('PHP Department welcome') ->textBody(sprintf('Hello, %s!', $this->name)); } } ... $this->emailService->run( new User([ 'email' => $recipient[0], 'first_name' => $recipient[1], ]), new TestEmail($recipient[1]) );