Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/245.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Yii2 SwiftMailer不通过默认邮件()函数发送电子邮件_Php_Yii2_Swiftmailer_Yii2 Advanced App - Fatal编程技术网

Php Yii2 SwiftMailer不通过默认邮件()函数发送电子邮件

Php Yii2 SwiftMailer不通过默认邮件()函数发送电子邮件,php,yii2,swiftmailer,yii2-advanced-app,Php,Yii2,Swiftmailer,Yii2 Advanced App,以下是我的配置: 'mailer' => [ 'class' => 'yii\swiftmailer\Mailer', 'viewPath' => '@common/mail', 'transport' => [ 'class' => 'Swift_MailTransport', ], 'useFileTranspo

以下是我的配置:

'mailer' => [
            'class' => 'yii\swiftmailer\Mailer',
            'viewPath' => '@common/mail',
            'transport' => [
                'class' => 'Swift_MailTransport',
            ],
            'useFileTransport' => False,
        ],
我甚至尝试过以下方法:

'mailer' => [
            'class' => 'yii\swiftmailer\Mailer',
            'viewPath' => '@common/mail',
            'useFileTransport' => False,
        ],
我正在使用以下代码发送电子邮件:

var_dump(\Yii::$app->mailer->compose()
                    ->setTo($email)
                    ->setFrom(\Yii::$app->params['supportEmail'])
                    ->setSubject('Message subject')
                    ->setTextBody('Plain text content')
                    ->setHtmlBody('<b>HTML content</b>')
                    ->send());
我尝试了他们默认的
SMTP
,我没有得到任何错误,但仍然得到了false

我们正在共享托管环境。我需要检查任何PHP设置吗

尝试此配置

'mailer' => [
            'class' => 'yii\swiftmailer\Mailer',
            'useFileTransport'=>false,
            // 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.

            'transport' => [
                'class' => 'Swift_SmtpTransport',
                'host' => 'smtp.gmail.com',
                'username' => 'yourmail@gmail.com',
                'password' => 'yourpassword',
                'port' => '465',
                'encryption' => 'ssl',
            ],
        ],
希望有帮助:)

尝试此配置

'mailer' => [
            'class' => 'yii\swiftmailer\Mailer',
            'useFileTransport'=>false,
            // 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.

            'transport' => [
                'class' => 'Swift_SmtpTransport',
                'host' => 'smtp.gmail.com',
                'username' => 'yourmail@gmail.com',
                'password' => 'yourpassword',
                'port' => '465',
                'encryption' => 'ssl',
            ],
        ],

希望有帮助:)

我想用默认的mail()函数而不是smtp来配置它。我想用默认的mail()函数而不是smtp来配置它。可能与
Swift\u MailTransport无关
现在不安全,改用
Swift\u-SendmailTransport
。可能与
Swift\u-MailTransport
无关,现在不安全,改用
Swift\u-SendmailTransport