YII2 - Mail always saved as files but not sent despite useFileTransport=false
<p>I am trying to send mails from Yii2 production site, but mails always arrive in runtime/mail folder.</p>

<p>This is the action in the controller:</p>

<pre><code> public function actionTestmail()
 {
   Yii::$app
        -&gt;mailer
        -&gt;compose(['html' =&gt; 'courriel-test-html']          
        )
        -&gt;setFrom("user@domain.fr") //-&gt;setFrom([Yii::$app-&gt;params['supportEmail'] =&gt; Yii::$app-&gt;name . ' robot'])
        -&gt;setTo('me@mydomain.com')
        -&gt;setSubject('Email for test purpose')
        -&gt;send();
     return $this-&gt;render('index');
 }
</code></pre>

<p><strong>index.php</strong></p>

<pre><code>// 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))-&gt;run();
</code></pre>

<p><strong>config/web.php</strong></p>

<pre><code>    'Smtpmail'=&gt;array(
                'class'=&gt;'application.extensions.smtpmail.PHPMailer',
                'useFileTransport' =&gt; false,
                'Host'=&gt;"fox.o2switch.net",
                'Username'=&gt;'user@domain.fr',//a valid account 
                'Password'=&gt;'******',//the actual password for the account above
                'Mailer'=&gt;'smtp',
                'Port'=&gt;587,
                'SMTPAuth'=&gt;true, 
                'SMTPSecure' =&gt; 'tls',
            ),

or 

      'mailer' =&gt; [
            'class' =&gt; 'yii\swiftmailer\Mailer',
            'useFileTransport' =&gt; false,
            'transport' =&gt; [
                'class' =&gt; 'Swift_SmtpTransport',
                'host' =&gt; 'fox.o2switch.net',
                'username' =&gt; 'user@domain.fr',
                'password' =&gt; '*******',
                'port' =&gt; '25',
               // 'encryption' =&gt; 'tls',
            ],
        ],
</code></pre>

<p>In both cases the result is the same, a file in runtime/mail but no mail actually sent. What is wrong?</p>