2017 © Pedro Peláez
 

library mail-service

image

systream/mail-service

  • Tuesday, May 9, 2017
  • by systream
  • Repository
  • 1 Watchers
  • 2 Stars
  • 5 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 0 % Grown

The README.md

Mail Service

Mail template and queueing service., (*1)

Installation

You can install this package via packagist.org with composer., (*2)

composer require systream/mail-service, (*3)

composer.json:, (*4)

"require": {
    "systream/mail-service": "*"
}

This library requires php 5.6 or higher., (*5)

Usage examples

MailQueue

Create a simple mailQueue item with factory., (*6)

$item = Mail\MailQueueItem\MailQueueItemFactory::make('subject', 'Message for {$name}', 'recipient@email.hu', 'Recipent Name', array('name' => 'John'));

Formatters

You can add message formatters to a mailqueue item. For example a token formatter, which can replace the given tokens in the message and the subject., (*7)

You can add multiple message formatter., (*8)

$tokenFormatter = new TokenFormatter($tokens);
// ...
$mailQueueItem = new MailQueueItem($message);
$mailQueueItem->addMessageFormatter($tokenFormatter);

Mail templates

Mail templates gives the basic content of the message. This library provides a simple StringMailTemplate object, but you can easily add your custom. The only thing you needed to do is implement MailTemplateInterface., (*9)

$mailTemplate = new StringMailTemplate($body, $subject);

Recipients

One or more recipient can be added to the message., (*10)

$message = new Message($mailTemplate);
$message->addRecipient(new Recipient($recipientEmail, $recipientName));

Custom mailqueue item

$tokenFormatter = new TokenFormatter($tokens);
$mailTemplate = new StringMailTemplate($body, $subject);
$message = new Message($mailTemplate);
$message->addRecipient(new Recipient($recipientEmail, $recipientName));
$mailQueueItem = new MailQueueItem($message);
$mailQueueItem->addMessageFormatter($tokenFormatter);

Send message

You need a mailer and a Queue hadler., (*11)

Mail sender

This repository provides a phpmailler adapter for MailSenderInterface, (*12)


$PHPMailer = new \PHPMailer(true); $PHPMailer->isSMTP(); $PHPMailer->Host = "127.0.0.1"; $PHPMailer->Port = 1025; $PHPMailer->SetFrom('test@unit.test'); $mailer = new Mail\MailSender\PHPMailerAdapter($PHPMailer);

Queue handler

Sqlite queue handler
$mail = new Mail($mailer, new Mail\QueueHandler\SqliteQueHandlerAdapter());

Sending immediate

$mail->send($item);

Add item to queue

$mail->queue($item);

Process Queue

$mail->consume();

Set logger

You can use any PSR-3 compatible logger, for example monolog., (*13)

$mail->setLogger($logger);

Test

Build Status, (*14)

The Versions

09/05 2017

dev-master

9999999-dev

  Sources   Download

MIT

The Requires

 

The Development Requires

by Peter Tihanyi

mail template token mailqueue mailq mailque

09/05 2017

0.9.1

0.9.1.0

  Sources   Download

MIT

The Requires

 

The Development Requires

by Peter Tihanyi

mail template token mailqueue mailq mailque

03/05 2017

0.9.0

0.9.0.0

  Sources   Download

MIT

The Requires

 

The Development Requires

by Peter Tihanyi

mail template token mailqueue mailq mailque