markguinn/silverstripe-email-helpers
Composer 安装命令:
composer require markguinn/silverstripe-email-helpers
包简介
Silverstripe extension containing SMTP mailer class and some other classes for HTML emails
README 文档
README
Contains replacement Mailer object that utilizes PHPMailer to send e-mail via SMTP instead of php's mail() function. Optionally, TLS can be enabled for secure communication with the SMTP server and a charset for the e-mail encoding can be specified. In addition, embedded CSS, plus a specified external CSS file, can be inlined into the email's HTML.
Also includes a drop-in replacement for the Email class called StyledHtmlEmail. If used with HTML emails it allows you to include a style section at the top of the email which will then be inlined as style attributes on the actual html tags to promote better compatibility across email clients.
Requirements
Silverstripe 3.0+
Installation
Install via composer:
composer require markguinn/silverstripe-email-helpers:dev-master
This module installs PHPMailer and Emogrifier:
Usage
SMTP Mailer
To use the SMTP mailer add the following code to your _config.php:
$encryption = 'tls'; // use tls $charset = 'UTF-8'; // use specified charset if set // you can specify a port as in 'yourserver.com:587' $mailer = new SmtpMailer('yourserver.com', 'username', 'password', $encryption, $charset); Email::set_mailer($mailer); // or Injector::inst()->registerService($mailer, 'Mailer');
Alternatively, any of these can be set using the config system like so:
SmtpMailer:
host: yourserver.com
user: username
password: password
encryption: tls
charset: UTF-8
And then in _config.php:
Email::set_mailer( new SmtpMailer() );
Emogrified Smtp Mailer
If you wish to embed CSS into your email's HTML then use the EmogrifiedSmtpMailer class. Add the following code to your _config.php:
$encryption = 'ssl'; // use ssl $charset = 'UTF-8'; $externalcssfile = 'themes/{yourtheme}/css/externalcssfile.css'; // specify the path to your css file $SMTPDebug = 2; // Levels 0-4 available $logfailedemail = true; // Log a notice with PHPMailer's error information $mailer = new EmogrifiedSmtpMailer('yourserver.com', 'username', 'password', $encryption, $charset, $externalcssfile, $SMTPDebug, $logfailedemail); Email::set_mailer($mailer); // or Injector::inst()->registerService($mailer, 'Mailer');
Alternatively, any of these can be set using the config system like so:
EmogrifiedSmtpMailer:
host: yourserver.com
user: username
password: password
encryption: ssl
charset: UTF-8
cssfile: 'themes/{yourtheme}/css/externalcssfile.css'
SMTPDebug: 2
logfailedemail: true
And then in _config.php:
Email::set_mailer( new EmogrifiedSmtpMailer() );
Styled Html Email
To use the styled email, just literally use the StyledHtmlEmail class where you'd normally use the Email class and add a single style tag in the body of the email. For example:
<style type="text/css"> .bigred { color: red; font-size: 30px; } </style> Hello <span class="bigred">CUSTOMERS</span>.
Would be sent as:
Hello <span style="color:red; font-size:30px">CUSTOMERS</span>.
markguinn/silverstripe-email-helpers 适用场景与选型建议
markguinn/silverstripe-email-helpers 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 45.67k 次下载、GitHub Stars 达 31, 最近一次更新时间为 2013 年 01 月 15 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「email」 「smtp」 「silverstripe」 「emogrifier」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 markguinn/silverstripe-email-helpers 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 markguinn/silverstripe-email-helpers 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 markguinn/silverstripe-email-helpers 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Analytics chooser extensions for site settings.
Extensible library for building notifications and sending them via different delivery channels.
The Message Submission Agent Diagnostics tool (msadiag) facilitates testing the compatibility of third party message submission agents.
Email+ extends Kirby's email capabilities by adding support for multiple email services using the same Kirby email API.
CitaNZ's SilverStripe picture object and field for SilverStripe 4
统计信息
- 总下载量: 45.67k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 31
- 点击次数: 20
- 依赖项目数: 3
- 推荐数: 0
其他信息
- 授权协议: Unknown
- 更新时间: 2013-01-15