dev-master
9999999-dev https://github.com/ddd-php/Mail
MIT
The Requires
- php >=5.3.0
by Joseph ROUFF
mail ddd
Wallogit.com
2017 © Pedro Peláez
Mail is a component which allow to create/send email easily whatever mailer mecanism you use (SwiftMailer...)., (*1)
Using Composer, just require the ddd/components package:, (*2)
``` javascript { "require": { "ddd/components": "dev-master" } }, (*3)
## Usage ## ### 1. Prepare your email ### #### Method A #### ```php <?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')) ;
<?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()
;
With Mail you can send your emails with the mailer of your choice (SwiftMailer, Amazon SES, Compain monitor...):, (*4)
$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.
TextMail with SwiftMailer as MailerInterface implementation.TextMail with "Amazon SES" as MailerInterface implementation.MailerException should be thrown whatever implementation used.HtmlEmail with SwiftMailer.HtmlEmail AND TextEmail.TextMail with "Compaign Monitor" as MailerInterface implementation.TextMail the content should be strip of all HTML tags.HtmlMail the plain text version should be generated automatically.
MIT
mail ddd