ddd / mail
dev-master
2013-08-15 13:34 UTC
Requires
- php: >=5.3.0
This package is not auto-updated.
Last update: 2024-09-23 15:15:33 UTC
README
Mail 是一个组件,允许您使用任何邮件发送机制(SwiftMailer...)轻松创建/发送电子邮件。
安装
使用 Composer,只需要求 ddd/components
包
{ "require": { "ddd/components": "dev-master" } }
用法
1. 准备您的电子邮件
方法 A
<?php use Ddd\Mail\Model\TextMail; use Ddd\Mail\Model\Contact; use Ddd\Mail\Infra\Mailer\SwiftMailer; use Ddd\Mail\Infra\Mailer\AmazonSesMailer; $mail = new TextMail(new Contact('support@github.com', 'Github')); $mail ->compose('[Github] Payment receipt', 'Here my body formatted in Text format') ->addRecipient(new Contact('customer1@gmail.com')) ->addRecipient(new Contact('customer2@gmail.com', 'Customer 2')) ;
方法 B
<?php use Ddd\Mail\MailBuilder; use Ddd\Mail\Infra\Mailer\SwiftMailer; use Ddd\Mail\Infra\Mailer\AmazonSesMailer; $mail = MailBuilder::create('support@github.com', 'Github') ->compose('[Github] Payment receipt', 'Here my body formatted in Text format') ->addRecipients(array( 'customer1@gmail.com', 'customer2@gmail.com' => 'Customer 2' )) ->getTextMail() ;
2. 发送它###
使用 Mail
,您可以使用您选择的邮件发送器(SwiftMailer、Amazon SES、Compain monitor...)发送您的电子邮件
$mail->send(new SwiftMailer($container->get('swift_mailer'))); // Send email with SwiftMailer. $mail->send(new AmazonSesMailer($container->get('aws.ses.client'))); // Send same email with Amazon SES.
冰箱
- 作为用户,我应该能够使用非常简单的 API 创建可发送的基本电子邮件。
- 作为用户,我应该能够使用 SwiftMailer 作为
MailerInterface
实现发送基本的TextMail
。 - 作为用户,我应该能够使用 "Amazon SES" 作为
MailerInterface
实现发送基本的TextMail
。 - [ ][Chore] 作为用户,当发生任何错误时,无论使用哪种实现,都应该抛出
MailerException
。 - 作为用户,我应该能够创建一个不涉及任何域对象的邮件。
- 作为用户,我可以将一组联系人作为收件人,从而启用 "Newsletter" 模式。
- 作为用户,我能够使用 SwiftMailer 发送基本的
HtmlEmail
。 - 作为用户,我可以为
HtmlEmail
和TextEmail
添加附件。 - 作为用户,我可以提供副本收件人。
- 作为用户,我可以提供密件抄送收件人。
- 作为用户,联系人始终应该是有效的。
- 作为用户,我应该能够更改默认的 UTF-8 编码。
- 作为用户,我应该能够使用 "Compaign Monitor" 作为
MailerInterface
实现发送基本的TextMail
。 - 作为用户,当我在
TextMail
中将 HTML 内容作为正文时,内容应该删除所有 HTML 标签。 - 作为用户,当我在
HtmlMail
中将 HTML 内容作为正文时,应自动生成纯文本版本。 - 作为 Amazon SES 用户,我应该能够在标题(To:、From: 等)中放置特殊字符。
致谢
- Joseph Rouff rouffj@gmail.com