sobit/swiftmailer-component

Component for Yii Framework based application which provides simple configuration interface for Swift Mailer library.

dev-master 2014-06-04 18:50 UTC

This package is not auto-updated.

Last update: 2024-04-22 22:19:11 UTC


README

Component for Yii Framework based application which provides simple configuration interface for Swift Mailer library.

Installation

Add dependency to your composer.json file:

{
    "require": {
        "sobit/swiftmailer-component": "dev-master"
    }
}

Update your protected/config/main.php file:

<?php

Yii::setPathOfAlias('vendor', dirname(__FILE__) . '/../../vendor');

return array(
    'components' => array(
        'mailer' => array(
            'class' => 'vendor.sobit.swiftmailer-component.SwiftMailerComponent',

            'swiftBasePath' => dirname(__FILE__) . '/../../vendor/swiftmailer/swiftmailer',

            'host'     => 'localhost', // smtp host
            'port'     => 25,          // smtp port
            'username' => null,        // username
            'password' => null,        // password
            'security' => null,        // security, e.g. "ssl"
        ),
    ),
);

Usage

Most simple usage example:

$message = Yii::app()->mailer
    ->createMessage('Test subject', 'Test body content')
    ->setFrom(array('john@doe.com' => 'John Doe'))
    ->setTo(array('receiver@domain.org', 'other@domain.org' => 'A name'))
;
Yii::app()->mailer->send($message);