2017 © Pedro Peláez
 

library mail

mail related package

image

wscore/mail

mail related package

  • Saturday, November 4, 2017
  • by asaokamei
  • Repository
  • 1 Watchers
  • 1 Stars
  • 14 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

Mail

Wrapper classes for SwiftMailer to simplify some operations., (*1)

  • Framework agnostic.
  • License: MIT License.
  • PSR: PSR-1, PSR-2, and PSR-4.

Basic Usage

It's as simple as 1, 2, and 3..., (*2)

use WScore\Mail\Transport\Transport;
use WScore\Mail\Mailer;

// 1. create a transport
$transport = Transport::forgeSmtp();

// 2. create a mailer
$mailer = Mailer::newInstance($transport);

// 3. send mails
$mailer->sendText('hello world', function(Swift_Message $message) {
    $message->setTo('test@example.com', 'tested');
});

Message Default

You can create a MessageDefault object to set a default message in Mailer. The methods in MessageDefault objects, which start with with, are immutable call., (*3)

// somewhere in a config file. 
use WScore\Mail\MessageDefault;
$default = MessageDefault::newInstance()
    ->withFrom('from@example.com', 'from address');
    ->withReturnPath('bad-mail@example.com')
    ->withReplyTo('sender@example.com', 'sender name');

$mailer = Mailer::newInstance($transport)
    ->setMessageDefault($default);

// later on...
$mailer->setMessageDefault(
    $mailer->getMessageDefault()->withBulk() // send bulk mail?
);
$mailer->sendHtml('

hi

', function(Swift_Message $message) { $message->setTo('to@example.com'); });

Or, just use a closure as MessageDefault., (*4)

Japanese ISO-2022

sending Japanese in ISO2022 encoding. You must call Transport::goJapaneseIso2022() and use $mailer->sendJIS(...) method as;, (*5)

Transport::goJapaneseIso2022();
$transport = Transport::forgeSmtp();
$mailer = Mailer::newInstance($transport);
$mailer->sendJIS('some japanese text here',
    function(Swift_Message $message) {
        $message->setTo('test@example.com', 'tested');
});

Use SMTP transport when sending emails in ISO2022 encoding based on my experience..., (*6)

The Versions

04/11 2017

dev-master

9999999-dev

mail related package

  Sources   Download

MIT

The Requires

 

by Asao Kamei

02/10 2015

1.0.0

1.0.0.0

mail related package

  Sources   Download

MIT

The Requires

 

by Asao Kamei