Email Yii2将验证发送到电子邮件

Email Yii2将验证发送到电子邮件,email,yii2,Email,Yii2,任何知道如何在用户成功后向电子邮件发送验证的人都可以在系统上注册他们的信息…我希望任何人都可以逐步解释…我是否应该编辑此内容,或者有任何解决方案或建议: Yii::$app->mail->compose() ->setFrom('somebody@domain.com') ->setTo('myemail@yourserver.com') ->setSubject('Email sent from Yii2-Swiftmailer') ->send()

任何知道如何在用户成功后向电子邮件发送验证的人都可以在系统上注册他们的信息…我希望任何人都可以逐步解释…我是否应该编辑此内容,或者有任何解决方案或建议:

Yii::$app->mail->compose()
 ->setFrom('somebody@domain.com')
 ->setTo('myemail@yourserver.com')
 ->setSubject('Email sent from Yii2-Swiftmailer')
 ->send();
我已经这样配置了swiftmailer:

'mail' => [
         'class' => 'yii\swiftmailer\Mailer',
         'transport' => [
             'class' => 'Swift_SmtpTransport',
             'host' => 'localhost',
             'username' => 'username',
             'password' => 'password',
             'port' => '587', 
             'encryption' => 'tls', 
         ],

您应该使用“mailer”的配置,而不是像这样的“mail” 设置
'useFileTransport'=>false

在这种情况下,邮件服务器的传输设置是gmail 如果使用其他邮件服务器,则必须正确设置相关参数

'components' => [
       .........
       '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,//set this property to false to send mails to real email addresses
        //comment the following array to send mail using php's mail function
        'transport' => [
            'class' => 'Swift_SmtpTransport',
            'host' => 'smtp.gmail.com',
            'username' => 'yourusername@gmail.com',
            'password' => 'yourpassword',
            'port' => '587',
            'encryption' => 'tls',
        ],
    ],

好的。我已经这么做了。那么如何在成功注册后将验证发送到电子邮件如果你没有特定的需要,你最好使用像这些扩展这样的用户扩展。在所有你需要的功能中,包括确认电子邮件和许多其他useuf功能如果你使用gmail。端口为587,如果您使用其他邮件服务器,则必须指定正确的方式。对于gmail服务器,必须使用端口:587和编码:tls