I'm trying to send mail, but getting error like.
Unknown Property – yii\base\UnknownPropertyException
Getting unknown property: yii\web\Application::mail
After changing Yii::$app->mail->compose()
to Yii::$app->mailer->compose()
I got this error
Invalid Parameter – yii\base\InvalidParamException
Invalid path alias:@backend/mail
I'm not getting where i'm doing mistake.
I'm using yii-app-basic.
config/console.php
...'components' => ['mailer' => ['class' => 'yii\swiftmailer\Mailer', ], ],...
config/web.php
...'components' => ['mailer' => ['class' => 'yii\swiftmailer\Mailer','viewPath' => '@backend/mail','useFileTransport' => true,'transport' => ['class' => 'Swift_SmtpTransport','host' => 'localhost','username' => 'root','password' => '','port' => '8080','encryption' => 'tls', ], ], ],...
SiteController.php
<?phpnamespace app\controllers;use Yii;use yii\filters\AccessControl;use yii\web\Controller;use yii\filters\VerbFilter;use yii\swiftmailer\Mailer;class SiteController extends Controller{ public function actionRegister() { Yii::$app->mail->compose() ->setFrom('enamRaj@gmail.com') ->setTo('Raj@infotech.com') ->setSubject('This is a test mail') ->send(); }}
I'm new to Yii. I don't have much idea. If this is a silly question,please forgive me.
Taking help from Mailing- Yii 2.0. But, not getting much idea.Please help me to send email