dev-master
9999999-devmail related package
MIT
The Requires
by Asao Kamei
1.0.0
1.0.0.0mail related package
MIT
The Requires
by Asao Kamei
mail related package
Wrapper classes for SwiftMailer to simplify some operations., (*1)
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'); });
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)
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)
mail related package
MIT
mail related package
MIT