Yii2 advanced app “错误”;类别';Swift#U嵌入文件';“未找到”;当我尝试使用yii2 advanced发送电子邮件时

Yii2 advanced app “错误”;类别';Swift#U嵌入文件';“未找到”;当我尝试使用yii2 advanced发送电子邮件时,yii2-advanced-app,Yii2 Advanced App,我尝试使用自动发送邮件构建应用程序 在我构建yii2advanced之前,我尝试了yii2basic和我的代码工作。 但当我尝试使用yii2 advanced时,我犯了错误 未找到类“Swift\u EmbeddedFile” 有人能帮我吗 这是我的代码: 在/common/config/main-local.php中编写代码 return [ 'components' => [ 'mailer' => [ 'class' => 'yii\swiftma

我尝试使用自动发送邮件构建应用程序

在我构建yii2advanced之前,我尝试了yii2basic和我的代码工作。 但当我尝试使用yii2 advanced时,我犯了错误

未找到类“Swift\u EmbeddedFile”

有人能帮我吗

这是我的代码:

在/common/config/main-local.php中编写代码

return [
'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' => false,
        'transport' => [
               'class' => 'Swift_SmtpTransport',
               'host' => 'mysmtp',
               'username' => 'myusername',
               'password' => 'mypassword',
               'port' => 'myport',
         ],
    ],
],];
以及我在MyController中的代码:

Yii::$app->mailer->compose('layouts/index.php', [
                        'imageFileName' => Yii::getAlias('@app/mail/layouts/images/logo.png'),
                        'facebook' => Yii::getAlias('@app/mail/layouts/images/facebook.png'),
                        'twitter' => Yii::getAlias('@app/mail/layouts/images/twitter.png'),
                        'pinterest' => Yii::getAlias('@app/mail/layouts/images/pinterest.png')
                        ]) // a view rendering result becomes the message body here
                    ->setFrom('from@email.com')
                    ->setTo($model->email)
                    ->setSubject('Message Test 3')
                    ->send();
注:我有Swiftmailer分机


提前感谢各位的帮助。

您是否尝试在此高级模板项目上再次运行
composer update
?[已解决]在我运行composer update之后。现在没有错误,但我的电子邮件是空的。我的html视图未包含在电子邮件中。你能帮我@Bizley检查一下是否能找到
layouts/index.php
的路径吗。还请记住,
@app
别名自动指向高级模板中当前正在运行的应用程序,因此可能需要像
@console
@backend
那样指定它。