PHP code example of devrusspace / yii2-kennwort-email-sender
1. Go to this page and download the library: Download devrusspace/yii2-kennwort-email-sender 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/ */
devrusspace / yii2-kennwort-email-sender example snippets
return [
'components' => [
'kennwort' => [
'class' => 'Devrusspace\KennwortYii2\ApiClient',
'token' => 'ваш_токен_созданный_в_личном_кабинете',
'defaultSenderId' => 'идентификатор_email_из_вашего_списка_отправителей',
],
]
];
$template = 'user/registration';
$mailTo = ['[email protected]' => 'Имя получателя'];
$params = ['var1' => 'значение переменной для подстановки в шаблон'];
$result = Yii::$app->kennwort->sendEmail($template, $mailTo, $params);
$emailId = $result->email->id; // идентификатор отправленного сообщения
print_r($result);
stdClass Object
(
[result] => 1
[email] => stdClass Object
(
[id] => 42bbd42d6dafddb160d61530f8ce9bb2
)
)
$mailTo = ['[email protected]' => 'Имя получателя'];
$subject = 'Заголовок письма';
$body = 'Html код содержимого письма';
$result = Yii::$app->kennwort->sendEmailDefaultSenderBody($mailTo, $subject, $body);
$senderId = 'идентификатор_email_из_вашего_списка_отправителей'
$mailTo = ['[email protected]' => 'Имя получателя'];
$subject = 'Заголовок письма';
$body = 'Html код содержимого письма';
$result = Yii::$app->kennwort->sendEmailBody($senderId, $mailTo, $subject, $body);
$result = Yii::$app->kennwort->getEmail($emailId);
print_r($result);
stdClass Object
(
[id] => 8993cc6ffbfd04173d846c0113a97abe
[time_add] => 1671777031
[time_sended] => 1671777031
[time_opened] =>
[time_clicked] =>
[time_opened_last] =>
[time_clicked_last] =>
[opened] =>
[cliked] =>
[is_test] =>
)
$page = 1;
$perPage = 50;
$result = Yii::$app->kennwort->getTransactionsTemplates($page, $perPage);
print_r($result);
Array
(
[0] => stdClass Object
(
[id] => daf1670c9aa1b629a294b4556ffa600d
[key] => user/registration
[name] => user / Приветсвенное письмо
[mail_subject] => Приветсвуем в сервисе транзакционных рассылок
[mail_pre_text] => {{userName}} отправлять через нас просто 🤠
)
)
$page = 1;
$perPage = 50;
$result = Yii::$app->kennwort->getSenders($page, $perPage);
print_r($result);
Array
(
[0] => stdClass Object
(
[id] => 13d7c0f5a82f34ad9a76a163bc80a7f4
[time_add] => 1669741763
[email] => [email protected]
[name] => Сервис транзакционных рассылок
)
)