README.md 927 Bytes
Newer Older
1 2
SwiftMailer Extension for Yii 2
===============================
Paul Klimov committed
3

4
This extension provides a `SwiftMailer` mail solution for Yii 2.
Paul Klimov committed
5

6
To use this extension,  simply add the following code in your application configuration:
Paul Klimov committed
7

8 9 10 11 12 13 14 15 16 17 18 19
```php
return [
	//....
	'components' => [
		'mail' => [
			'class' => 'yii\swiftmailer\Mailer',
		],
	],
];
```

You can then send an email as follows:
Paul Klimov committed
20

21 22
```php
Yii::$app->mail->compose('contact/html')
23 24 25
     ->setFrom('from@domain.com')
     ->setTo($form->email)
     ->setSubject($form->subject)
26 27
     ->send();
```
Paul Klimov committed
28

29
For further instructions refer to the related section in the Yii Definitive Guide.
Paul Klimov committed
30 31 32 33 34 35 36 37


Installation
------------

The preferred way to install this extension is through [composer](http://getcomposer.org/download/).

Either run
38

Paul Klimov committed
39 40 41 42 43
```
php composer.phar require yiisoft/yii2-swiftmailer "*"
```

or add
44

Paul Klimov committed
45 46 47 48
```json
"yiisoft/yii2-swiftmailer": "*"
```

49
to the require section of your composer.json.