修改common/main-local.php:

<?php
return [
    'components' => [
        'db' => [
            'class' => 'yii\db\Connection',
            'dsn' => 'mysql:host=localhost;dbname=',
            'username' => '',
            'password' => '',
            'charset' => 'utf8',
        ],
        'mailer' => [
            'class' => 'yii\swiftmailer\Mailer',
            'viewPath' => '@common/mail',
            // 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' => true,
             'useFileTransport' =>false,//这句一定有,false发送邮件,true只是生成邮件在runtime文件夹下,不发邮件
             'transport' => [  
                'class' => 'Swift_SmtpTransport',  
                'host' => 'smtp.qq.com',  //每种邮箱的host配置不一样
                'username' => '7138784@qq.com',  
                'password' => '',  
                'port' => '465',  
                'encryption' => 'ssl',

                ],   
        ],
    ],
     'language' => 'zh-CN',//启用国际化支持
    'sourceLanguage' => 'zh-CN',//源代码采用中文
    'timeZone' => 'Asia/Shanghai', //设置时区
];