使用Swift邮件程序的Yii2高级模板电子邮件在前端工作正常但不在后端工作

问题描述 投票:0回答:1

在我的本地xampp中使用Yii2开发项目。使用swift邮件程序,电子邮件部分从前端工作正常但从后端工作不正常,发送电子邮件后它甚至没有显示错误但返回发送状态为true,以下是我的码

前端配置,``

'components' => [
'mailer' => [
    'class' => 'yii\swiftmailer\Mailer',
    'useFileTransport' => false,
    'transport' => [
        'class' => 'Swift_SmtpTransport',
        'host' => 'xxxx,
        'username' => 'xxx,
        'password' => 'xxx',
        'port' => '465',
        'encryption' => 'ssl',                            
    ], 
  ], 
  ...............  

后端配置,

'components' => [
    'mailer' => [
        'class' => 'yii\swiftmailer\Mailer',
        'useFileTransport' => false,
        'transport' => [
            'class' => 'Swift_SmtpTransport',
            'host' => 'cloudlinux4.ukdns.biz',
            'username' => '[email protected]',
            'password' => 'Test091ixV2',
            'port' => '465',
            'encryption' => 'ssl',                            
          ], 
        ......

发送电子邮件的示例代码,

 Yii::$app->mailer->compose()
         ->setFrom('[email protected]')
         ->setTo('[email protected]')
         ->setSubject('Email sent from Yii2-Swiftmailer')
         ->send();

我想在后端控制器或配置中添加任何额外的代码吗?请帮助我。

yii2 swiftmailer
1个回答
0
投票

也许你在BACKEND的config / main-local.php中有一个覆盖设置,检查出来。

© www.soinside.com 2019 - 2024. All rights reserved.