Mail always saved as files but not sent despite useFileTransport=false

Hi,

I am trying to send mails from production site but mails always arrive in runtime/mail folder


     public function actionTestmail()

     {

       Yii::$app

            ->mailer

            ->compose(['html' => 'courriel-test-html']          

            )

            ->setFrom("user@domain.fr") //->setFrom([Yii::$app->params['supportEmail'] => Yii::$app->name . ' robot'])

            ->setTo('me@mydomain.com')

            ->setSubject('Email for test purpose')

            ->send();

         return $this->render('index');

     }

<?php

index.php


// comment out the following two lines when deployed to production

//defined('YII_DEBUG') or define('YII_DEBUG', true);

//defined('YII_ENV') or define('YII_ENV', 'dev');


require(__DIR__ . '/../vendor/autoload.php');

require(__DIR__ . '/../vendor/yiisoft/yii2/Yii.php');


$config = require(__DIR__ . '/../config/web.php');


(new yii\web\Application($config))->run();

[b]

config/web.php[/b]


'Smtpmail'=>array(

            'class'=>'application.extensions.smtpmail.PHPMailer',

            'useFileTransport' => false,

            'Host'=>"fox.o2switch.net",

            'Username'=>'user@domain.fr',//a valid account 

            'Password'=>'******',//the actual password for the account above

            'Mailer'=>'smtp',

            'Port'=>587,

            'SMTPAuth'=>true, 

            'SMTPSecure' => 'tls',

        ),

or




  'mailer' => [

        'class' => 'yii\swiftmailer\Mailer',

        'useFileTransport' => false,

        'transport' => [

            'class' => 'Swift_SmtpTransport',

            'host' => 'fox.o2switch.net',

            'username' => 'user@domain.fr',

            'password' => '*******',

            'port' => '25',

           // 'encryption' => 'tls',

        ],

    ],

In both cases the result is the same, a file in runtime/mail but no mail actually sent

I use like the second example, there is no problem. How do you use it for sending mails?

I use it as shown in the first code block (controller)

It seems that the line


'useFileTransport' => false, 

is not read.

If I change the beginning of my actionTestmail() function like this:


$mailer= Yii::$app->mailer;

$mailer->useFileTransport = false;

$mailer->compose()->…



it works fine. Is this a bug or did I do something wrong?

Eventually I made it out:

There was a mailer component duplicate in config.