uam/postmark-swiftmailer-bundle
Composer 安装命令:
composer require uam/postmark-swiftmailer-bundle
包简介
Symfony bundle to provide a Postmark SwiftMailer service
README 文档
README
A Symfony2 bundle that provides a SwiftMailer Transport implementation based on Postmark's API.
While a Symfony app by no means requires you to use SwiftMailer for sending emails, there are many benefits to doing so: log of emails sent, ability to redirect to a single delivery address during development, etc.
This bundle allows you to use the Postmark API as a SwiftMailer transport in your Symfony app. This provides you with the benefits of both SwiftMailer and of the Postmark service.
This bundle is in its early stages of development, and can hardly be viewed as production-ready. Usage in production is at your peril.
Requirements
You need an active account at https://postmarkapp.com/ and a Postmark API key.
This bundle relies on the MZPostmarkBundle and will include it automatically.
Installation
Add package to your project's composer.json:
"require": {
"uam/postmark-swiftmailer-bundle": "dev-master",
…
}
Register this bundle as well as the MZPostmarkBundle in AppKernel.php:
public function registerBundles()
{
bundles = (
// …
new MZ\PostmarkBundle\MZPostmarkBundle(),
new UAM\Bundle\PostmarkSwiftMailerBundle\UAMPostmarkSwiftMailerBundle(),
);
return bundles();
}
Configuration
Configure the MZPostmarkBundle as per that bundle's documentation:
# app/config/config.php
mz_postmark:
api_key: %postmark_api_key%
from_email: %postmark_from_email%
from_name: %postmark_from_name%
use_ssl: %postmark_use_ssl%
timeout: %postmark_timeout%
Update your SwiftMailer configuration to use the uam_postmark SwiftMailer transport provided by this bundle.
# app/config.php
swiftmailer:
transport: uam_postmark
There is no configuration specific to this bundle.
Usage
This bundle creates a service aliased uam_postmark which implements a SwiftMailer transport based on the Postmark API.
Create your SwiftMailer messages as usual. When sent, the messages will be routed through the uam_postmark transport to the Postmark servers.
SwitfMailer plugins
The UAMPostmarkTransport should in theory be able to support all swiftmailer plugins. However, so far only the Redirecting plugin has been tested to some extent.
Redirecting
Edit your swiftmailer configuration as per the symfony SwiftMailerBundle documentation:
# app/config.php
swiftmailer:
delivery_address: test@example.com
Known issues
HTML message content shows up as raw text
Make sure that the HTML body in your emails are set as a MIME part:
$message
->addPart($htmlBody, 'text/html');
Email count
The Swift_Transport#send() method returns the count of messages sent.
This bundle's implementation will return the number of emails sent to recipients included in the 'To' header. Emails sent to 'Cc' and 'Bcc' recipients will not be included in the email count returned.
The reason for this is that the Postmark API, while supporting Cc and Bcc recipients, does not seem to include any data about them in its response to a request to send a message.
Failed recipients
The Swift_Transport#send() method's second parameter is designed to be passed a variable which collects the email addresses of failed recipients.
This is not supported by this bundle's implementation of the Swift_Transport interface. By design, this implementation will make a single call to the Postmark API for all the recipients (To, Cc, and Bcc included included in a single call, as opposed to a call per recipient). This single call will fail if one of the email addresses is invalid.
Redirecting custom headers are lost
SwiftMailer's Redirecting plugin adds custom headers to your message to reflect the original recipients ('X-Swift-To', 'X-Swift-Cc', 'X-Swift-Bcc'). These headers are not recognized by the Postmark API and are not retained in the actual message sent via Postmark.
uam/postmark-swiftmailer-bundle 适用场景与选型建议
uam/postmark-swiftmailer-bundle 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 2.91k 次下载、GitHub Stars 达 2, 最近一次更新时间为 2013 年 05 月 29 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「symfony」 「bundle」 「swiftmailer」 「postmarkapp」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 uam/postmark-swiftmailer-bundle 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 uam/postmark-swiftmailer-bundle 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 uam/postmark-swiftmailer-bundle 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Parse a generic mail stream, and convert it to a SwiftMailer Message
2lenet/EasyAdminPlusBundle
The bundle for easy using json-rpc api on your project
Database Spool Bundle for SwiftMailer and Symfony 3
Integrate Emogrifier plugin into SilverStripe.
Provide a way to secure accesses to all routes of an symfony application.
统计信息
- 总下载量: 2.91k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 12
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2013-05-29