選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

README.md 1.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. SwiftMailer Extension for Yii 2
  2. ===============================
  3. This extension provides a [SwiftMailer](http://swiftmailer.org/) mail solution for Yii 2.
  4. This repository is a git submodule of <https://github.com/yiisoft/yii2>.
  5. Please submit issue reports and pull requests to the main repository.
  6. For license information check the [LICENSE](LICENSE.md)-file.
  7. Installation
  8. ------------
  9. The preferred way to install this extension is through [composer](http://getcomposer.org/download/).
  10. Either run
  11. ```
  12. php composer.phar require --prefer-dist yiisoft/yii2-swiftmailer
  13. ```
  14. or add
  15. ```json
  16. "yiisoft/yii2-swiftmailer": "~2.0.0"
  17. ```
  18. to the require section of your composer.json.
  19. Usage
  20. -----
  21. To use this extension, simply add the following code in your application configuration:
  22. ```php
  23. return [
  24. //....
  25. 'components' => [
  26. 'mailer' => [
  27. 'class' => 'yii\swiftmailer\Mailer',
  28. ],
  29. ],
  30. ];
  31. ```
  32. You can then send an email as follows:
  33. ```php
  34. Yii::$app->mailer->compose('contact/html')
  35. ->setFrom('from@domain.com')
  36. ->setTo($form->email)
  37. ->setSubject($form->subject)
  38. ->send();
  39. ```
  40. For further instructions refer to the related section in the Yii Definitive Guide.