PHP code example of rmrevin / yii2-postman
1. Go to this page and download the library: Download rmrevin/yii2-postman 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/ */
rmrevin / yii2-postman example snippets
<?
return [
// ...
'components' => [
// ...
'postman' => [
'class' => 'rmrevin\yii\postman\Component',
'driver' => 'smtp',
'default_from' => ['[email protected] ', 'Mailer'],
'subject_prefix' => 'Sitename / ',
'subject_suffix' => null,
'table' => '{{%postman_letter}}',
'view_path' => '/email',
'smtp_config' => [
'host' => 'smtp.domain.cpom',
'port' => 465,
'auth' => true,
'user' => '[email protected] ',
'password' => 'password',
'secure' => 'ssl',
'debug' => false,
]
],
],
// ...
];
<?
return [
// ...
'components' => [
// ...
'postman' => [
'class' => 'rmrevin\yii\postman\Component',
// ...
'smtp_config' => [
// ...
'secure' => '',
'smtpAutoTls' => false,
]
],
],
// ...
];
<?
return [
// ...
'components' => [
// ...
'postman' => [
'class' => 'rmrevin\yii\postman\Component',
],
],
// ...
];
<?
// ...
(new \rmrevin\yii\postman\RawLetter())
->setSubject('Subject')
->setBody('Message body')
->addAddress('[email protected] ')
->addBccAddress(['[email protected] ']);
if(!$Letter->send()){
echo $Letter->getLastError();
}
// path to view algorithm:
// Yii::$app->controller->module->getViewPath() . Postman::$view_path . '/' . 'message-view.php'
// path to view: /protected/views/email/message-view.php
(new \rmrevin\yii\postman\ViewLetter)
->setSubject('Subject')
->setBodyFromView('letter-view', [
'name' => 'Rosy',
'date' => date('Y-m-d')
])
->addAddress(['[email protected] ', 'John Smith'])
->addAttachment('/path/to/file.tar.gz');
if(!$Letter->send()){
echo $Letter->getLastError();
}
LetterModel::cron($num_letters_per_step = 10)
php yii migrate/up --migrationPath=@vendor/rmrevin/yii2-postman/migrations/