digitaledgeit/zf2-mail-module

本包的最新版本(0.1.0)没有可用的许可证信息。

0.1.0 2014-06-16 10:57 UTC

This package is not auto-updated.

Last update: 2024-09-28 15:06:15 UTC


README

一个简化 ZF2 Mail 使用模块。

安装

将模块添加到您的 composer.json 文件中,并运行 composer install

"digitaledgeit/zf2-mail-module": "dev-master"

配置

将模块添加到您的 config/application.config.php 文件中的 modules 键下

'modules' => [
	'DeitMailModule',
],

将配置添加到您的 local.phpmodule.config.php 文件中

'deit_mail' => [

	//an array containing type and options keys or a string containing a service name
	'transport' => [
		'type'      => '',              //null, file, sendmail or smtp
		'options'   => [                //see the transport options for selected type at http://framework.zend.com/manual/2.1/en/modules/zend.mail.introduction.html
		],
	],

	'renderer'  => 'ViewRenderer'        //a string containing a service name
],

发送邮件

//get the service
$service = $serviceManager->get('deit_mail_service');

//send a message containing plain text and HTML versions
$service->sendMixedMessage(
	[
		'to'            => 'fred@example.com',
		'from'          => 'wilma@example.com',
		'subject'       => 'A test message from my app',
		'attachments'   => [
            [
                'type'      => 'text/html',
                'name'      => 'test1.html',
                'content'   => '<html><head><title>Test HTML Page</title></head><body><h1>Test HTML Page</h1></body></html>'
            ],
            [
                'type'      => 'text/html',
                'name'      => 'test2.html',
                'content'   => './path/to/the-file.html'
            ]
        ]
	],
	[
		'text/plain'    => 'email/hello-text',
		'text/html'     => 'email/hello-html'
	],
	[
		'name' => 'World!'
	]
);