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条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥20 双层网络上信息-疾病传播
    • ¥50 paddlepaddle pinn
    • ¥20 idea运行测试代码报错问题
    • ¥15 网络监控:网络故障告警通知
    • ¥15 django项目运行报编码错误
    • ¥15 请问这个是什么意思?
    • ¥15 STM32驱动继电器
    • ¥15 Windows server update services
    • ¥15 关于#c语言#的问题:我现在在做一个墨水屏设计,2.9英寸的小屏怎么换4.2英寸大屏
    • ¥15 模糊pid与pid仿真结果几乎一样