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
。