smtp
This commit is contained in:
parent
0671346ce8
commit
15c801f579
@ -18,7 +18,8 @@
|
|||||||
"josantonius/session": "^2.0",
|
"josantonius/session": "^2.0",
|
||||||
"firebase/php-jwt": "^6.10",
|
"firebase/php-jwt": "^6.10",
|
||||||
"k-adam/env-editor": "^2.0",
|
"k-adam/env-editor": "^2.0",
|
||||||
"guzzlehttp/guzzle": "^7.9"
|
"guzzlehttp/guzzle": "^7.9",
|
||||||
|
"phpmailer/phpmailer": "^6.9"
|
||||||
},
|
},
|
||||||
"autoload": {
|
"autoload": {
|
||||||
"psr-4": {
|
"psr-4": {
|
||||||
|
83
composer.lock
generated
83
composer.lock
generated
@ -4,7 +4,7 @@
|
|||||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||||
"This file is @generated automatically"
|
"This file is @generated automatically"
|
||||||
],
|
],
|
||||||
"content-hash": "9b8653e1a4f451d6e125cb1732ffdeef",
|
"content-hash": "18fbb67ed0b66029e924b0a6d32f646f",
|
||||||
"packages": [
|
"packages": [
|
||||||
{
|
{
|
||||||
"name": "brick/math",
|
"name": "brick/math",
|
||||||
@ -1607,6 +1607,87 @@
|
|||||||
],
|
],
|
||||||
"time": "2024-11-07T17:46:48+00:00"
|
"time": "2024-11-07T17:46:48+00:00"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "phpmailer/phpmailer",
|
||||||
|
"version": "v6.9.3",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/PHPMailer/PHPMailer.git",
|
||||||
|
"reference": "2f5c94fe7493efc213f643c23b1b1c249d40f47e"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/PHPMailer/PHPMailer/zipball/2f5c94fe7493efc213f643c23b1b1c249d40f47e",
|
||||||
|
"reference": "2f5c94fe7493efc213f643c23b1b1c249d40f47e",
|
||||||
|
"shasum": ""
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"ext-ctype": "*",
|
||||||
|
"ext-filter": "*",
|
||||||
|
"ext-hash": "*",
|
||||||
|
"php": ">=5.5.0"
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"dealerdirect/phpcodesniffer-composer-installer": "^1.0",
|
||||||
|
"doctrine/annotations": "^1.2.6 || ^1.13.3",
|
||||||
|
"php-parallel-lint/php-console-highlighter": "^1.0.0",
|
||||||
|
"php-parallel-lint/php-parallel-lint": "^1.3.2",
|
||||||
|
"phpcompatibility/php-compatibility": "^9.3.5",
|
||||||
|
"roave/security-advisories": "dev-latest",
|
||||||
|
"squizlabs/php_codesniffer": "^3.7.2",
|
||||||
|
"yoast/phpunit-polyfills": "^1.0.4"
|
||||||
|
},
|
||||||
|
"suggest": {
|
||||||
|
"decomplexity/SendOauth2": "Adapter for using XOAUTH2 authentication",
|
||||||
|
"ext-mbstring": "Needed to send email in multibyte encoding charset or decode encoded addresses",
|
||||||
|
"ext-openssl": "Needed for secure SMTP sending and DKIM signing",
|
||||||
|
"greew/oauth2-azure-provider": "Needed for Microsoft Azure XOAUTH2 authentication",
|
||||||
|
"hayageek/oauth2-yahoo": "Needed for Yahoo XOAUTH2 authentication",
|
||||||
|
"league/oauth2-google": "Needed for Google XOAUTH2 authentication",
|
||||||
|
"psr/log": "For optional PSR-3 debug logging",
|
||||||
|
"symfony/polyfill-mbstring": "To support UTF-8 if the Mbstring PHP extension is not enabled (^1.2)",
|
||||||
|
"thenetworg/oauth2-azure": "Needed for Microsoft XOAUTH2 authentication"
|
||||||
|
},
|
||||||
|
"type": "library",
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"PHPMailer\\PHPMailer\\": "src/"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"LGPL-2.1-only"
|
||||||
|
],
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "Marcus Bointon",
|
||||||
|
"email": "phpmailer@synchromedia.co.uk"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Jim Jagielski",
|
||||||
|
"email": "jimjag@gmail.com"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Andy Prevost",
|
||||||
|
"email": "codeworxtech@users.sourceforge.net"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Brent R. Matzelle"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "PHPMailer is a full-featured email creation and transfer class for PHP",
|
||||||
|
"support": {
|
||||||
|
"issues": "https://github.com/PHPMailer/PHPMailer/issues",
|
||||||
|
"source": "https://github.com/PHPMailer/PHPMailer/tree/v6.9.3"
|
||||||
|
},
|
||||||
|
"funding": [
|
||||||
|
{
|
||||||
|
"url": "https://github.com/Synchro",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"time": "2024-11-24T18:04:13+00:00"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "phpoption/phpoption",
|
"name": "phpoption/phpoption",
|
||||||
"version": "1.9.3",
|
"version": "1.9.3",
|
||||||
|
41
kernel/helpers/SMTP.php
Normal file
41
kernel/helpers/SMTP.php
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace kernel\helpers;
|
||||||
|
|
||||||
|
use PHPMailer\PHPMailer\Exception;
|
||||||
|
use PHPMailer\PHPMailer\PHPMailer;
|
||||||
|
|
||||||
|
class SMTP
|
||||||
|
{
|
||||||
|
public PHPMailer $mail;
|
||||||
|
public string $host;
|
||||||
|
public int $port;
|
||||||
|
public string $username;
|
||||||
|
public string $password;
|
||||||
|
|
||||||
|
public function __construct(array $config = [])
|
||||||
|
{
|
||||||
|
$this->mail = new PHPMailer(true);
|
||||||
|
$this->mail->isSMTP();
|
||||||
|
$this->mail->SMTPAuth = true;
|
||||||
|
$this->mail->SMTPDebug = 0;
|
||||||
|
$this->host = $config['host'] ?? '';
|
||||||
|
$this->port = $config['port'] ?? 587;
|
||||||
|
$this->username = $config['username'] ?? '';
|
||||||
|
$this->password = $config['password'] ?? '';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public function send(string $address): void
|
||||||
|
{
|
||||||
|
$this->mail->setFrom($this->username, $this->host);
|
||||||
|
$this->mail->addAddress($address);
|
||||||
|
$this->mail->Subject = 'Код подтверждения';
|
||||||
|
$body = '<p><strong>«Hello, world!» </strong></p>';
|
||||||
|
$this->mail->msgHTML($body);
|
||||||
|
|
||||||
|
$this->mail->send();
|
||||||
|
}
|
||||||
|
}
|
@ -10,9 +10,11 @@ use kernel\Flash;
|
|||||||
use kernel\helpers\Debug;
|
use kernel\helpers\Debug;
|
||||||
use kernel\helpers\Files;
|
use kernel\helpers\Files;
|
||||||
use kernel\helpers\RESTClient;
|
use kernel\helpers\RESTClient;
|
||||||
|
use kernel\helpers\SMTP;
|
||||||
use kernel\modules\module_shop_client\services\ModuleShopClientService;
|
use kernel\modules\module_shop_client\services\ModuleShopClientService;
|
||||||
use kernel\Request;
|
use kernel\Request;
|
||||||
use kernel\services\ModuleService;
|
use kernel\services\ModuleService;
|
||||||
|
use PHPMailer\PHPMailer\Exception;
|
||||||
|
|
||||||
class ModuleShopClientController extends AdminController
|
class ModuleShopClientController extends AdminController
|
||||||
{
|
{
|
||||||
@ -118,4 +120,21 @@ class ModuleShopClientController extends AdminController
|
|||||||
$this->redirect('/admin/module_shop_client', 302);
|
$this->redirect('/admin/module_shop_client', 302);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public function actionAuth(): void
|
||||||
|
{
|
||||||
|
$request = new Request();
|
||||||
|
$address = $request->post("email");
|
||||||
|
$mail = new SMTP([
|
||||||
|
'host' => 'smtp.mail.ru',
|
||||||
|
'port' => 587,
|
||||||
|
'username' => 'chancellery@itguild.info',
|
||||||
|
'password' => 'iBdGdxmJk1mnySJYtXc0'
|
||||||
|
]);
|
||||||
|
|
||||||
|
$mail->send($address);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -15,6 +15,7 @@ App::$collector->group(["prefix" => "admin"], function (RouteCollector $router){
|
|||||||
App::$collector->get('/view/{id}', [\kernel\modules\module_shop_client\controllers\ModuleShopClientController::class, 'actionView']);
|
App::$collector->get('/view/{id}', [\kernel\modules\module_shop_client\controllers\ModuleShopClientController::class, 'actionView']);
|
||||||
App::$collector->get('/delete', [\kernel\modules\module_shop_client\controllers\ModuleShopClientController::class, 'actionDelete']);
|
App::$collector->get('/delete', [\kernel\modules\module_shop_client\controllers\ModuleShopClientController::class, 'actionDelete']);
|
||||||
App::$collector->get('/update', [\kernel\modules\module_shop_client\controllers\ModuleShopClientController::class, 'actionUpdate']);
|
App::$collector->get('/update', [\kernel\modules\module_shop_client\controllers\ModuleShopClientController::class, 'actionUpdate']);
|
||||||
|
App::$collector->post('/auth', [\kernel\modules\module_shop_client\controllers\ModuleShopClientController::class, 'actionAuth']);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
@ -9,7 +9,7 @@ echo \kernel\helpers\Html::h(2, "Форма авторизации");
|
|||||||
$form = new ActiveForm();
|
$form = new ActiveForm();
|
||||||
$form->beginForm("/admin/module_shop_client/auth/");
|
$form->beginForm("/admin/module_shop_client/auth/");
|
||||||
|
|
||||||
$form->field(\itguild\forms\inputs\TextInput::class, 'key', [
|
$form->field(\itguild\forms\inputs\TextInput::class, 'email', [
|
||||||
'class' => "form-control",
|
'class' => "form-control",
|
||||||
'placeholder' => 'Email',
|
'placeholder' => 'Email',
|
||||||
])
|
])
|
||||||
|
Loading…
Reference in New Issue
Block a user