【问题标题】:Alias "yii.swiftmailer" is invalid. Make sure it points to an existing directory or file别名“yii.swiftmailer”无效。确保它指向现有目录或文件
【发布时间】:2016-02-06 09:12:07
【问题描述】:

我已经根据文档配置了 yii2-swiftmailer,但是当我发送邮件时显示此错误:

别名“yii.swiftmailer”无效。确保它指向一个现有的目录或文件。

C:\xampp\htdocs\hotel\protected\controllers\HomeController.php(250)
246 
247     public function actionMail()
248     {
249 
250         Yii::app()->mailer->compose()
251             ->setTo('example@gmail.com')
252             ->setFrom('example2@gmail.com')
253             ->setSubject('Invite')
254             ->setTextBody('Hello!')
255             ->send();
256 
257     }
258 }

还有我的扩展文件夹... 扩展\yii2-swiftmailer

和我的配置:

'mailer' => [
            'class' => 'yii\swiftmailer\Mailer',
            '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' => '',
                'password' => '',
                'port' => '587',
                'encryption' => 'tls',
            ],
        ],

【问题讨论】:

    标签: php yii yii2 swiftmailer yii-extensions


    【解决方案1】:

    那是因为您尝试将 swiftmailer 用于 yii2 而不是版本 1。尝试另一个完全专用于 yii 第一版的扩展程序http://www.yiiframework.com/extension/swiftmailer/

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-06-17
      • 2018-03-04
      • 2017-12-22
      • 1970-01-01
      • 2012-11-30
      • 2018-12-18
      相关资源
      最近更新 更多