Php 未收到yii2用户dektrium模块注册电子邮件
我有麻烦了。 我通过以下链接安装yii2用户模块Php 未收到yii2用户dektrium模块注册电子邮件,php,yii2,Php,Yii2,我有麻烦了。 我通过以下链接安装yii2用户模块 当我尝试注册时,我收到了一条成功消息,但我没有收到确认电子邮件。 我用的是OpenServer config/web.php <?php $params = require(__DIR__ . '/params.php'); $config = [ 'id' => 'basic', 'language' => 'ru-RU', 'basePath' => dirname(__DIR__),
当我尝试注册时,我收到了一条成功消息,但我没有收到确认电子邮件。 我用的是OpenServer config/web.php
<?php
$params = require(__DIR__ . '/params.php');
$config = [
'id' => 'basic',
'language' => 'ru-RU',
'basePath' => dirname(__DIR__),
'bootstrap' => ['log'],
'modules' => [
'user' => [
'class' => 'dektrium\user\Module',
'mailer' => [
'sender' => ['name@gmail.com' => 'Vlad'], // or ['no-reply@myhost.com' => 'Sender name']
'welcomeSubject' => 'Welcome subject',
'confirmationSubject' => 'Confirmation subject',
'reconfirmationSubject' => 'Email change subject',
'recoverySubject' => 'Recovery subject',
],
],
],
'components' => [
'request' => [
// !!! insert a secret key in the following (if it is empty) - this is required by cookie validation
'cookieValidationKey' => 'QqvFfvH3g3PwMMu_bRRHB4Qz0uPJwiB-',
],
'cache' => [
'class' => 'yii\caching\FileCache',
],
// 'user' => [
// 'identityClass' => 'app\models\User',
// 'enableAutoLogin' => true,
// ],
'errorHandler' => [
'errorAction' => 'site/error',
],
'mailer' => [
'class' => 'yii\swiftmailer\Mailer',
// 'transport' => [
// 'class' => 'Swift_SmtpTransport',
// 'host' => 'smtp.gmail.com',
// 'username' => 'name@gmail.com',
// 'password' => 'mypassword',
// 'port' => '587',
// 'encryption' => 'tls',
// ],
// send all mails to a file by default. You have to set
// 'useFileTransport' to false and configure a transport
// for the mailer to send real emails.
// 'useFileTransport' => false,
],
'log' => [
'traceLevel' => YII_DEBUG ? 3 : 0,
'targets' => [
[
'class' => 'yii\log\FileTarget',
'levels' => ['error', 'warning'],
],
],
],
'db' => require(__DIR__ . '/db.php'),
'urlManager' => [
'enablePrettyUrl' => true,
'showScriptName' => false,
'rules' => [
],
],
],
'params' => $params,
];
if (YII_ENV_DEV) {
// configuration adjustments for 'dev' environment
$config['bootstrap'][] = 'debug';
$config['modules']['debug'] = [
'class' => 'yii\debug\Module',
];
$config['bootstrap'][] = 'gii';
$config['modules']['gii'] = [
'class' => 'yii\gii\Module',
];
}
return $config;
邮件程序组件应与模型组件处于同一级别。 您可以按如下方式对其进行配置:
'mailer' => [
'class' => 'yii\swiftmailer\Mailer',
'viewPath' => '@app/mailer',
'useFileTransport' => false,
'transport' => [
'class' => 'Swift_SmtpTransport',
'host' => 'smtp.mailtrap.io', // your host, here using fake email server (https://mailtrap.io/). You can use gmail: 'host' => 'smtp.gmail.com'
'username' => 'your host username',
'password' => 'your host password',
'port' => '2525',
'encryption' => 'tls',
],
],
在您的环境处于开发模式之前,您将永远不会收到电子邮件。 您有3种不同的方式阅读电子邮件:
您需要配置您的
swiftmailer
设置