Browse Source

minor touch up of swiftmailer.

tags/2.0.0-alpha
Qiang Xue 12 years ago
parent
commit
500371253e
  1. 9
      Mailer.php
  2. 63
      README.md

9
Mailer.php

@ -7,9 +7,9 @@
namespace yii\swiftmailer;
use Yii;
use yii\base\InvalidConfigException;
use yii\mail\BaseMailer;
use Yii;
/**
* Mailer based on SwiftMailer library.
@ -116,13 +116,14 @@ class Mailer extends BaseMailer
*/
protected function createTransport(array $config)
{
if (array_key_exists('class', $config)) {
if (isset($config['class'])) {
$className = $config['class'];
unset($config['class']);
} else {
$className = 'Swift_MailTransport';
}
$transport = call_user_func([$className, 'newInstance']);
/** @var \Swift_MailTransport $transport */
$transport = $className::newInstance();
if (!empty($config)) {
foreach ($config as $name => $value) {
if (property_exists($transport, $name)) {
@ -139,4 +140,4 @@ class Mailer extends BaseMailer
}
return $transport;
}
}
}

63
README.md

@ -1,17 +1,32 @@
Yii 2.0 Public Preview - SwiftMailer Mail Solution
==================================================
SwiftMailer Extension for Yii 2
===============================
Thank you for choosing Yii - a high-performance component-based PHP framework.
This extension provides a `SwiftMailer` mail solution for Yii 2.
If you are looking for a production-ready PHP framework, please use
[Yii v1.1](https://github.com/yiisoft/yii).
To use this extension, simply add the following code in your application configuration:
Yii 2.0 is still under heavy development. We may make significant changes
without prior notices. **Yii 2.0 is not ready for production use yet.**
```php
return [
//....
'components' => [
'mail' => [
'class' => 'yii\swiftmailer\Mailer',
],
],
];
```
You can then send an email as follows:
[![Build Status](https://secure.travis-ci.org/yiisoft/yii2.png)](http://travis-ci.org/yiisoft/yii2)
```php
Yii::$app->mail->compose('contact/html')
->from('from@domain.com')
->to($form->email)
->subject($form->subject)
->send();
```
This is the yii2-swiftmailer extension.
For further instructions refer to the related section in the Yii Definitive Guide.
Installation
@ -20,39 +35,15 @@ Installation
The preferred way to install this extension is through [composer](http://getcomposer.org/download/).
Either run
```
php composer.phar require yiisoft/yii2-swiftmailer "*"
```
or add
```json
"yiisoft/yii2-swiftmailer": "*"
```
to the require section of your composer.json.
*Note: You might have to run `php composer.phar selfupdate`*
Usage & Documentation
---------------------
This extension has to be registered prior to usage.
To enable this view renderer add it to the $rendereres property of your view object.
Example:
```php
<?php
// config.php
return [
//....
'components' => [
'mail' => [
'class' => 'yii\swiftmailer\Mailer',
],
],
];
```
For further instructions refer to the related section in the yii guide.
to the require section of your composer.json.

Loading…
Cancel
Save