php - How to call Swift mailer in yii2 with console controller? -


yii::$app           ->mailer           ->compose(               ['html' => 'remainder-html', 'text' => 'remainder-text'],               ['user' => $user,'interview'=>$interview]           )           ->setfrom([yii::$app->params['supportemail'] => yii::$app->name . ' robot'])           ->setto($user->email)           ->setsubject('contact request ' . $model->name)           ->send(); 

above code have used in console/controller advanced app in yii2. rest of things working mail not working. same code work when placed in backend/frontend controller. following error.

php user error 'yii\base\errorexception' message 'call undefined method compose'

yii2 applications use different configuration file console , web.

all need configure 'mailer' component in console configuration file. if using basic application template, 'config/console.php'.


Comments

Popular posts from this blog

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -