定制 phpbook/email 二次开发

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

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

phpbook/email

Composer 安装命令:

composer require phpbook/email

包简介

PHP Email Library For AWSSES, MAILGUN, SMTP, SPARKPOST

README 文档

README

About Email

  • A lightweight e-mail PHP library available for SMTP, AWSSES, MAILGUN AND SPARKPOST
  • Requires PHP Extension FINFO.

Composer Install

composer require phpbook/email

Declare Configurations

/********************************************
 * 
 *  Declare Configurations
 * 
 * ******************************************/

//Driver connection SMTP

\PHPBook\Email\Configuration\Email::setConnection('main',
	(new \PHPBook\Email\Configuration\Connection)
		->setName('Main')
		->setExceptionCatcher(function(String $message) {
			//the PHPBook Email does not throw exceptions, but you can take it here
			//you can store $message in database or something else
		})
		->setDriver((new \PHPBook\Email\Driver\SMTP)
			->setHost('host')
			->setPort(100)
			->setUser('user')
			->setPassword('password')
			->setSecure('tls')
			->setEmail('email@email.com')
			->setName('Jhon')
			->setEncode('utf8'))
);

//Driver connection AWSSES

\PHPBook\Email\Configuration\Email::setConnection('other',
	(new \PHPBook\Email\Configuration\Connection)
		->setName('Other')
		->setExceptionCatcher(function(String $message) {
			//the PHPBook Email does not throw exceptions, but you can take it here
			//you can store $message in database or something else
		})
		->setDriver((new \PHPBook\Email\Driver\AWSSES)
			->setKey('key')
			->setSecret('secret')
			->setRegion('region')
			->setEmail('email@email.com')
			->setName('Jhon'))
);


//Driver connection MAILGUN

\PHPBook\Email\Configuration\Email::setConnection('important', 
	(new \PHPBook\Email\Configuration\Connection)
		->setName('Important')
		->setExceptionCatcher(function(String $message) {
			//the PHPBook Email does not throw exceptions, but you can take it here
			//you can store $message in database or something else
		})
		->setDriver((new \PHPBook\Email\Driver\MAILGUN)
			->setKey('key')
			->setDomain('domain')
			->setEmail('email@email.com')
			->setName('Jhon'))
);

//Driver connection SPARKPOST

\PHPBook\Email\Configuration\Email::setConnection('backups', 
	(new \PHPBook\Email\Configuration\Connection)
		->setName('Backups')
		->setExceptionCatcher(function(String $message) {
			//the PHPBook Email does not throw exceptions, but you can take it here
			//you can store $message in database or something else
		})
		->setDriver((new \PHPBook\Email\Driver\SPARKPOST)
			->setKey('key')
			->setEmail('email@email.com')
			->setName('Jhon'))
);


//Set default connection by connection alias

\PHPBook\Email\Configuration\Email::setDefault('main');

//Getting connections

$connections = \PHPBook\Email\Configuration\Email::getConnections();

foreach($connections as $code => $connection) {

	$connection->getName(); 

	$connection->getDriver();

};

?>

Sending Emails

		

	//Connection code is not required if you set default connection

	$boolean = (new \PHPBook\Email\Email)
		->setConnectionCode('other')
		->setMessage(
			(new \PHPBook\Email\Message)
				->setFromName('example@email.com') //custom from name. not required.
				->setFromEmail('example@email.com') //custom from email. not required.
				->setTo(['jhon@email.com'])
				->setCc(['paul@email.com'])
				->setCco(['ana@email.com'])
				->setSubject('email subject')
				->setContent('my html body')
				->setAttach([
					(new \PHPBook\Email\Attach)->setFileAlias('myfile')->setFileBuffer('my-file-buffer'),
					(new \PHPBook\Email\Attach)->setFileAlias('myfile')->setFilePath('my/file/path')
				])
		)->dispatch();

	if ($boolean) {
		//sent
	};

		

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2018-06-14

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固