doutuan9357 2019-05-07 13:30 采纳率: 100%
浏览 66

错误:“调用未定义的方法ping。”使用Yii2和Swiftmailer

Any help would be highly appreciated.

I do not understand what I am doing wrong. I have used Swiftmailer before and it has never been this difficult to configure it.

I am using an advanced Yii2 project.

This is part of my backend/config/main.php (I have tried with backend/config/main-local.php, common/config/main.php and common/config/main-local.php just in case):

....
 'components' => [
 'mailer' => [
            'class' => 'yii\swiftmailer\Mailer',
            'useFileTransport' => false,
            'transport' => [
                'class' => 'Swift_SmtpTransport',
                'host' => 'localhost',
                'username' => 'name@example.com',
                'password' => 'password',
                'port' => '587',
                'encryption' => 'tls',
                'plugins' => [
                    [
                        'class' => 'Swift_Plugins_ThrottlerPlugin',
                        'constructArgs' => [20],
                    ],
                ],
            ],
        ],
....
],

This is part of my controller:

 public function actionTests()
    {  
    Yii::$app->mailer->compose()
            ->setFrom('name@example.com')
            ->setTo('name_2@example.com')
            ->setSubject('Email sent from Yii2-Swiftmailer')
            ->send();
    }

This is the error I am getting: enter image description here

enter image description here

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 c程序不知道为什么得不到结果
    • ¥40 复杂的限制性的商函数处理
    • ¥15 程序不包含适用于入口点的静态Main方法
    • ¥15 素材场景中光线烘焙后灯光失效
    • ¥15 请教一下各位,为什么我这个没有实现模拟点击
    • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
    • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
    • ¥20 有关区间dp的问题求解
    • ¥15 多电路系统共用电源的串扰问题
    • ¥15 slam rangenet++配置