小编Zei*_*eiZ的帖子

Yii2 SwiftMailer通过远程smtp服务器(gmail)发送电子邮件

我想通过我的Gmail帐户发送电子邮件.

我的邮件配置:

[
'class' => 'yii\swiftmailer\Mailer',
'useFileTransport' => false,//set this property to false to send mails to real email addresses
'transport' => [
    'class' => 'Swift_SmtpTransport',
    'host' => 'smtp.gmail.com',
    'username' => 'my@gmail.com',
    'password' => 'pass',
    'port' => '587',
    'encryption' => 'tls',
    ],
]
Run Code Online (Sandbox Code Playgroud)

我写了命令MailController:

<?php

namespace app\commands;

use yii\console\Controller;
use Yii;

/**
* Sanding mail
* Class MailController
* @package app\commands
*/
class MailController extends Controller
{
    private $from = 'my@gmail.com';
    private $to = 'to@gmail.com';

    public function actionIndex($type = 'test', …
Run Code Online (Sandbox Code Playgroud)

swiftmailer yii2

3
推荐指数
1
解决办法
3万
查看次数

标签 统计

swiftmailer ×1

yii2 ×1