iamiamp / yii2-mailgun
为 Yii 框架集成的 Mailgun
v0.0.1
2015-05-12 07:29 UTC
Requires
- mailgun/mailgun-php: ~1.8
- yiisoft/yii2: >=2.0.4
This package is not auto-updated.
Last update: 2024-09-18 19:14:13 UTC
README
为 Yii 框架集成的 Mailgun
安装
安装此扩展的首选方法是通过 composer。
运行以下命令之一
php composer.phar require --prefer-dist boundstate/yii2-mailgun "*"
或
"boundstate/yii2-mailgun": "*"
将以下内容添加到您的 composer.json 文件的 require 部分中。
使用方法
在应用配置中进行配置
'components' => [ ... 'mailer' => [ 'class' => 'boundstate\mailgun\Mailer', 'key' => 'key-example', 'domain' => 'mg.example.com', ], ... ],
要发送电子邮件,可以使用以下代码
Yii::$app->mailer->compose('contact/html', ['contactForm' => $form]) ->setFrom('from@domain.com') ->setTo($form->email) ->setSubject($form->subject) ->send();