dwolke / zf-mailer
Zend Framework 3 简易邮件发送器
1.0
2019-09-04 08:37 UTC
Requires
- php: ^5.6|^7.0
- zendframework/zend-mail: ~2.4
- zendframework/zend-servicemanager: ~2.4
- zendframework/zend-stdlib: ~2.4
- zendframework/zend-view: ~2.4
Requires (Dev)
- phpmd/phpmd: ^2.4
- phpunit/phpunit: ^7
- squizlabs/php_codesniffer: ^2.6
This package is auto-updated.
Last update: 2024-09-05 03:21:42 UTC
README
Zend Framework v3 简易邮件发送器
警告: 此模块目前处于高度开发中,不建议在生产环境中使用。
简介
ZfMailer 是一个基于 Zend\Mail 的简单邮件模块,适用于 Zend Framework 3。电子邮件可以是纯文本格式,也可以是符合 MIME 标准的“多部分”邮件。支持发送带附件的电子邮件。
目前,仅支持通过 SMTP 发送电子邮件。也许这个模块将来会扩展其他可能性。
安装
主要设置
- 通过运行以下命令将此模块添加到您的项目中:
$ composer require dwolke/zf-mailer
安装后
使用 composer 安装后,将模块添加到您的 application.config.php 中。
<?php return array( 'modules' => array( // ... 'ZfMailer', // ... ), // ... );
设置
将配置文件从 vendor/dwolke/zf-mailer/config/zfmailer.local.php.dist
复制到 config/autoload/zfmailer.local.php
,并根据需要更改值。
选项
以下选项可用:
- smart_host [数组] - 配置发送邮件的服务器
- server_name [字符串] - 服务器主机名
- server_port [字符串] - tcp 端口,默认为 25
- username [字符串] - 连接到服务器的用户名
- password [字符串] - 连接到服务器的密码
- encoding [字符串,可选] - 默认为 'UTF-8'
- default_from [字符串,可选] - 如果发送电子邮件时未指定发送者地址,将使用此电子邮件地址作为发送者。
- return_path [字符串,可选] - 反弹邮件发送的地址
- reply_to [字符串,可选] - 回复邮件发送的地址。
- x_mailer [字符串,optinal] - 向电子邮件添加 'X-Mailer' 头
- organization [字符串,optional] - 向电子邮件添加 'Organization' 头
用法
使用邮件发送器非常简单。
// get the service $mailer = $serviceManager->get('ZfMailer\Service\Mailer'); // create a new mail $mailer->createNewMail($recipient, $subject, $sender); // set the content and render the e-mail body $mailer->prepareAsMultipart($mailContent, $textTemplate, $htmlTemplate); // send the e-mail $mailer->sendEmail();
这就结束了。
版权 © 2012 - 2019 dwLabs。版权所有。😎