oliver-schoendorn/mailer
Composer 安装命令:
composer require oliver-schoendorn/mailer
包简介
A little zendframework/zend-mail wrapper for easy composition of mime mails.
README 文档
README
This is a little zendframework/zend-mail wrapper that will automagically construct proper multipart mime mails.
Please feel free to submit pull requests.
Installation
composer require oliver-schoendorn/mailer
Usage example
Create new Mail object and initialize mail meta data
<?php use OS\Mail\Mail; $mail = (new Mail()) ->setSubject('email subject') ->setSender('foo@bar.dev', 'Foo Bar') ->setFrom('foo@bar.dev', 'Foo Bar') ->setTo('receipt@bar.dev', 'Receipt name');
Add inline attachments
This is optional, but if you are using inline attachments, you have to keep track of the MailAttachment object, in order to reference it in the html mail body.
If an inline attachment is not being referenced, some mail clients will show the attachment or a preview below the mail, which might break your carefully crafted mail layout.
<?php use OS\Mail\MailAttachment; $inlineImage = (new MailAttachment('file.jpg')) ->setContent(fopen('path/to/file.jpg', 'r')) ->setMimeType('image/jpg'); $mail->addInlineAttachment($inlineImage);
Add body parts
<?php use Zend\Mime\Mime; use OS\Mail\MailBody; $mail->addBodyPart((new MailBody()) ->setMimeType(Mime::TYPE_TEXT) ->setContent('Plain text mail content')); $mail->addBodyPart((new MailBody()) ->setMimeType(Mime::TYPE_HTML) ->setContent('<html><body><p>Html mail content<img src="' . $inlineImage . '" /></p></body></html>'));
Add (non-inline) attachments
Usually, these only appear attachment in a context menu or similar, based on the mail client used.
<?php use OS\Mail\MailAttachment; $mail->addAttachment((new MailAttachment('file.jpg')) ->setContent(fopen('path/to/file.jpg', 'r')) ->setMimeType('image/jpg'));
Sending the mail
To send an mail, you can either define the transport object directly using the Zend classes or you can use the built in MailTransportFactory, which provides some type hinting.
<?php use OS\Mail\MailTransportFactory; $mailTransport = (new MailTransportFactory())->createSmtpTransportWithLogin( $config['mail']['user'], $config['mail']['pass'], $config['mail']['encryption'], $config['mail']['name'], $config['mail']['host'], $config['mail']['port'] ); $mail->send($mailTransport);
License
Copyright 2018 Oliver Schöndorn
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
oliver-schoendorn/mailer 适用场景与选型建议
oliver-schoendorn/mailer 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 42 次下载、GitHub Stars 达 0, 最近一次更新时间为 2017 年 08 月 01 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「mailer」 「zend-framework」 「mime-mails」 「composer-library」 「zend-mail」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 oliver-schoendorn/mailer 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 oliver-schoendorn/mailer 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 oliver-schoendorn/mailer 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Creates new sare mail transport for laravel applications
Wrapper of the Artax library
Universal minimalist database wrapper
Mandrill Api Integration for Yii2
Zend Framework 2 Basic LDAP Authentication Module
Build and send emails.
统计信息
- 总下载量: 42
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: Apache-2.0
- 更新时间: 2017-08-01