承接 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.35k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 1
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-08-24