S
S
Sergey2015-04-30 23:09:12
Yii
Sergey, 2015-04-30 23:09:12

How does swiftmailer work in Yii2 and how to connect it?

How does swiftmailer work in Yii2 and how to connect it?
Can someone post an example of the settings code?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexander N++, 2015-04-30
@sanchezzzhak

'mailer' => [
            'class' => 'yii\swiftmailer\Mailer',
            'viewPath' => '@app/mail',
            'transport' => [
                'class' => 'Swift_SmtpTransport',
                'host' => 'email-smtp.us-west-2.amazonaws.com',
                'username' => 'anu4yzgRtf3YP6Vq431QA6iqlatm',
                'password' => 'erBYPWIDq/banu4yzgRtf',
                'port' => '587',
                'encryption' => 'tls',
            ],
            //'useFileTransport' => true,
        ],

$HTML = \Yii::$app->view->render('@app/mail/remind', [
                'token' => $user->password_reset_token,
                'email' => $user->email,
                'url' => $url
            ]);

  Yii::$app->mailer->compose()
                ->setFrom('ОТ кого')
                ->setTo('Кому')
                ->setSubject('Тема')
                ->setHtmlBody( $HTML )
                ->send();

The same thing, only the template is specified in compose('contact/html')
Yii::$app->mailer->compose('contact/html')
     ->setFrom('[email protected]')
     ->setTo($form->email)
     ->setSubject($form->subject)
     ->send();

https://github.com/yiisoft/yii2-swiftmailer

A
at0m1x, 2016-08-20
@at0m1x

You can read more about how to set up mail sending step by step in Yii2 here .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question