PHP code example of tecsvit / yii2-mailer
1. Go to this page and download the library: Download tecsvit/yii2-mailer library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
tecsvit / yii2-mailer example snippets
...
'components' => [
...
'mailer' => [
'class' => '\tecsvit\mailer\components\Mailer',
'useFileTransport' => false,
'defaultTemplates' => [
'YOUR_NAME_TEMPLATE' => [
'subject' => 'Your_mail_subject',
'template' => 'Your_template_filename',
'senderMail' => 'Sender_Email',
'senderName' => 'Sender_Name',
],
],
'transport' => [
'class' => 'Swift_SmtpTransport',
'host' => 'your_host',
'username' => 'your_username',
'password' => 'your_pass',
'port' => 'your_port',
'encryption' => 'your_encryption',
],
],
...
...
'components' => [
...
'mailer' => [
'class' => '\tecsvit\mailer\components\Mailer',
'useFileTransport' => false,
'defaultTemplates' => [
'confirmPassword' => [
'subject' => 'Hi',
'template' => 'confirmPassword.php',
'senderMail' => '[email protected] ',
'senderName' => 'Admin',
],
'subscribe' => [
'subject' => 'Hi2',
'template' => 'subscribe.php',
'senderMail' => '[email protected] ',
'senderName' => 'Manager',
],
],
'transport' => [
'class' => 'Swift_SmtpTransport',
'host' => 'smtp.gmail.com',
'username' => '[email protected] ',
'password' => '4565456464',
'port' => '587',
'encryption' => 'tls',
],
],
...
<strong>Confirm Your Mail</strong>
<div>
For confirm your mail click on link: <a href="http://site.com/user/confirm-email?hash=<?= $hash
$toMail = '[email protected] ';
$data = ['hash' => $hash];
/** @var \tecsvit\mailer\components\Mailer $mailer */
$mailer = Yii::$app->mailer;
$mailer->sendMail($toMail, $data, 'confirmPassword');
bash
php composer.phar