When running in CLI by crontab i get the following error:
"sh: sendmail: command not found"
When i run in SSH the same commando it just works. So i tryed forcing "Swift_MailTransport" by doing this before my code starts:
\Yii::$app->setComponents([
'mailer' => [
'class' => 'yii\swiftmailer\Mailer',
'enableSwiftMailerLogging' => true,
'useFileTransport' => false,
'transport' => [
'class' => 'Swift_MailTransport',
]
],
]);
And the code (simple)
public function actionTest()
{
\Yii::$app->mailer->compose()
->setFrom('test2@example.com')
->setTo('test1@example.com')
->setSubject('Message subject')
->setTextBody('Plain text content')
->setHtmlBody('<b>HTML content</b>')
->send();
}
Does anyone know what i am doing wrong?