adt / mailer
Nette 邮件解决方案的终极选择。
v3.2
2023-05-28 05:54 UTC
Requires
- php: >=7.4
- guzzlehttp/guzzle: ^6.3|^7.0
- nette/di: ^2.3 || ^3.0
- nette/mail: ^2.3 | ^3.0 | ^4.0
- tracy/tracy: ^2.3
README
使用 adt/mail-api 来
- 为所有项目使用单个邮件服务,
- 确保更高的邮件送达率。
安装
composer
composer require adt/mailer
config.neon
extensions: adtMailer: ADT\Mailer\DI\AdtMailerExtension adtMailer: remote: api: yourAdtMailApiInstance.com:1234 # can be either static string or method, required key: yourPrivateKey error: # mode: silent => log and continue # mode: exception => throw mode: silent # all undelivered messages are stored here (applies to mode: silent) logDir: %logDir%/adt_mailer # if recipient is suppressed, this address receives notification and delist link # can be either an email address, url or a callback returning an email address or url suppressionControlAddress: @App\Model\SuppressionControl::decide
使用方法
// inject IMailer into $this->mailer // create message $message = new \Nette\Mail\Message; // send message $this->mailer->send($message);
“内部”发生了什么?
- 连接到 adt/mail-api 服务器。
- 消息被序列化并发送到那里。
- 如果连接/传输失败,下一步由
error.mode
配置决定
silent
: 将邮件存储到error.logDir
,使用 Tracy 记录日志,并继续执行;exception
: 不进行任何日志记录,直接抛出异常。