定制 adt/single-recipient-mailer 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

adt/single-recipient-mailer

最新稳定版本:v5.1

Composer 安装命令:

composer require adt/single-recipient-mailer

包简介

Component modifies `Nette\Mail\Message` to send all the emails to one address. Sutaible for non production environments.

README 文档

README

Component modifies Nette\Mail\Message to send all the emails to one address. Suitable for non production environments.

Original To, Cc and Bcc email addresses are stored in the subject of the email (for example: To: origTo@example.com; origTo2@example.com; Cc: origCc@example.com | My email subject).

Installation

$ composer require adt/single-recipient-mailer

Usage

via trait

Use ADT\SingleRecipient\SingleRecipient trait in your mailer and then use applySingleRecipient method to apply a single recipient logic to an original message.

namespace App\Model;

use ADT\SingleRecipient\SingleRecipient;
use \Nette\Mail\SendmailMailer;

class Mailer extends SendmailMailer
{
	use SingleRecipient;

	public function send(Message $mail): void
	{
		if ($this->singleRecipient) {
			$this->applySingleRecipient($mail, 'developers@myproject.com');
		}

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

via config

Register ADT\SingleRecipient\SingleRecipientMailer in your config.neon to use @sendmailMailer and redirect all emails to developers@myProject.com:

services:
	sendmailMailer:
		class: Nette\Mail\SendmailMailer
		autowired: no # this is important

	mail.mailer: \ADT\SingleRecipient\SingleRecipientMailer(@sendmailMailer, 'developers@myproject.com')

The autowired: no option is important because Nette DI container would not know which \Nette\Mail\IMailer to inject in your application.

via inheritance

You can also extend the class if you want to:

namespace App\Model;

use Nette\Mail\SendmailMailer;

class Mailer extends \ADT\SingleRecipient\SingleRecipientMailer 
{
	public function __construct() 
	{
		parent::__construct(new SendMailMailer, 'developers@myproject.com');
	}

	public function send(\Nette\Mail\Message $mail) 
	{
		parent::send($mail); # do not forget to call this
	}
}

You can disable redirecting to single recipient by passing empty value (e.g. NULL or zero-length string).

统计信息

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

GitHub 信息

  • Stars: 0
  • Watchers: 15
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 未知

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固