2017 © Pedro Peláez
 

library yii-swift-mailer

Wrapper of Swiftmailer for Yii framework version 1.x

image

ikirux/yii-swift-mailer

Wrapper of Swiftmailer for Yii framework version 1.x

  • Monday, May 18, 2015
  • by ikirux
  • Repository
  • 1 Watchers
  • 3 Stars
  • 10,033 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 1 Open issues
  • 1 Versions
  • 4 % Grown

The README.md

Yii-SwiftMailer

Wrapper of Swiftmailer for Yii framework version 1.x, (*1)

Current swiftmailer version supported 5.1.0, (*2)

It supports these features:, (*3)

  1. smtp, sendmail or mail transport
  2. ssl or tls security
  3. setTo, CC, BCC
  4. Attachment of dynamic (generate at runtime) and static files
  5. Embed files (statics and dynamic)
  6. Swiftmailer's plugin (AntiFlood, Throtter, Logger)

You can review the official documentation at http://swiftmailer.org/docs/introduction.html, (*4)

Installation

Using Composer:, (*5)

Simply add a dependency on "ikirux/yii-swift-mailer" to your project's composer.json file if you use Composer to manage the dependencies of your project. Here is a minimal example of a composer.json, (*6)

{
    "require": {
        "ikirux/yii-swift-mailer": "dev-master"
    }
}

for more information visits https://getcomposer.org/, (*7)

Using Git:, (*8)

Just clone the project inside your extension directory, (*9)

git clone git@github.com:ikirux/Yii-SwiftMailer.git`

Configuration:, (*10)

Set up yii component via config:, (*11)

'mailer' => [
    'class' => 'path.to.swiftMailer.SwiftMailer',

    // Using SMTP:
    'mailer' => 'smtp',
    // 'ssl' for "SSL/TLS" or 'tls' for 'STARTTLS'
    'security' => 'ssl', 
    'host' => 'localhost',
    'from' => 'admin@localhost',
    'username' => 'smptusername',
    'password' => '123456',

    // Activate the Logger plugin
    // more information http://swiftmailer.org/docs/plugins.html#using-the-logger-plugin
    //'activateLoggerPlugin' => true,

    // Activate the AntiFlood plugin
    // more information http://swiftmailer.org/docs/plugins.html#antiflood-plugin
    //'activateAntiFloodPlugin' => true,            
    //'setFloodPluginParams' => ['threshold' => 100, 'sleep' => 30],

    // Activate the Throtter plugin
    // more information http://swiftmailer.org/docs/plugins.html#throttler-plugin
    // Modes support 1 => SwiftMailer::BYTES_PER_MINUTE, 
    //               2 => SwiftMailer::MESSAGES_PER_SECOND 
    //               3 => SwiftMailer::MESSAGES_PER_MINUTE
    //'activateThrotterPlugin' => true,         
    //'setThrotterPluginParams' => ['rate' => 10, 'mode' => 3],
],  

Usage

Creating a Message, (*12)

Yii::app()->mailer->setSubject('A great subject')
    ->addAddress('mail@domain.com')
    ->setBody('Nice HTML message')
    ->setAltBody('Message plain text alternative')
    ->send();

Creating a Message With Several Recipients, (*13)

Yii::app()->mailer->setSubject('A great subject')
    ->addAddress(['mail@domain.com', 'mail2@domain.com'])
    ->addCcAddress('mail3@domain.com')
    ->addBccAddress(['mail4@domain.com', 'mail5@domain.com'])
    ->setBody('Nice HTML message')
    ->setAltBody('Message plain text alternative')
    ->send();

Attaching Files, (*14)

Yii::app()->mailer->setSubject('A great subject')
    ->addAddress('mail@domain.com')
    ->setBody('Nice HTML message')
    ->setAltBody('Message plain text alternative')
    ->addAttachment('/path/to/file.pdf', 'application/pdf', 'Nickname File.pdf')
    ->addAttachment('/path/to/file.jpg')
    ->send();

Attaching Dynamic Files, (*15)

// Create your file contents in the normal way, but don't write them to disk
$data = create_my_pdf_data();

Yii::app()->mailer->setSubject('A great subject')
    ->addAddress('mail@domain.com')
    ->setBody('Nice HTML message')
    ->setAltBody('Message plain text alternative')
    ->addDinamicAttachment($data, 'application/pdf', 'FileName.pdf')
    ->send();

Embedding Existing Files, (*16)

Yii::app()->mailer->setSubject('A great subject')
    ->addAddress('mail@domain.com')
    ->setBody(
    '<html>' .
    ' <head></head>' .
    ' <body>' .
    '  Here is an image {{image}}' .
    '  Rest of message' .
    ' </body>' .
    '</html>')
    ->setAltBody('Message plain text alternative')
    ->embedFile('{{image}}', '/path/to/file.jpg')
    ->send();

Embedding Dynamic Files, (*17)

// Create your file contents in the normal way, but don't write them to disk
$img_data = create_my_image_data();

Yii::app()->mailer->setSubject('A great subject')
    ->addAddress('mail@domain.com')
    ->setBody(
    '<html>' .
    ' <head></head>' .
    ' <body>' .
    '  Here is an image {{image}}' .
    '  Rest of message' .
    ' </body>' .
    '</html>')
    ->setAltBody('Message plain text alternative')
    ->embedDinamicFile('{{image}}', $img_data, 'image/jpeg', 'image.jpg')
    ->send();

Your feedback is very welcome!, (*18)

Have Fun!, (*19)

The Versions

18/05 2015

dev-master

9999999-dev

Wrapper of Swiftmailer for Yii framework version 1.x

  Sources   Download

GPL2

The Requires

 

by Carlos Pinto