nextras/mail-panel

MailPanel 是一个 Nette 框架的扩展,它可以捕获开发模式下发送的电子邮件,并在调试栏中显示。

v2.6.2 2023-05-06 17:05 UTC

README

Downloads this Month Stable version

Nextras Mail Panel 是 Nette 框架的扩展,它可以在开发模式下捕获发送的电子邮件,并在 Tracy 栏中显示。

屏幕截图

安装

  1. 通过 composer 安装库

    composer require nextras/mail-panel
  2. 更新本地配置(例如 config.local.neon)以将 Mail Panel 注册到 Tracy
    并将默认邮件发送者更改为 Nextras\MailPanel\FileMailer

    tracy:
    	bar:
    		- Nextras\MailPanel\MailPanel(%tempDir%/mail-panel-latte)
    
    services:
    	nette.mailer:
    		class: Nette\Mail\Mailer
    		factory: Nextras\MailPanel\FileMailer(%tempDir%/mail-panel-mails)

用法

消息必须通过注入的 Nette\Mail\Mailer 实例发送。

class ExamplePresenter extends BasePresenter
{
	/** @var Nette\Mail\Mailer @inject */
	public $mailer;


	public function actionSendMail()
	{
		$mail = new Nette\Mail\Message();
		$mail->setFrom('john.doe@example.com', 'John Doe');
		$mail->addTo('jack@example.com');
		$mail->setSubject('Order Confirmation');
		$mail->setHtmlBody('Hello Jack,<br>Your order has been accepted.');

		$this->mailer->send($mail);
	}
}

许可证

基于 Jan Drábek 的 MailPanel

新 BSD 许可证。请参阅完整的 许可证