update dependencies
This commit is contained in:
parent
23066e7a1d
commit
7b2d9cf296
110
Application/Controller/Admin/SmtpChecker.php
Normal file
110
Application/Controller/Admin/SmtpChecker.php
Normal file
@ -0,0 +1,110 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* https://www.d3data.de
|
||||
*
|
||||
* @copyright (C) D3 Data Development (Inh. Thomas Dartsch)
|
||||
* @author D3 Data Development - Daniel Seifert <info@shopmodule.com>
|
||||
* @link https://www.oxidmodule.com
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace D3\SmtpChecker\Application\Controller\Admin;
|
||||
|
||||
use Assert\Assert;
|
||||
use Assert\InvalidArgumentException;
|
||||
use Net_SMTP;
|
||||
use OxidEsales\Eshop\Application\Controller\Admin\AdminDetailsController;
|
||||
use OxidEsales\Eshop\Application\Model\Shop;
|
||||
use OxidEsales\Eshop\Core\Registry;
|
||||
use PEAR;
|
||||
|
||||
class SmtpChecker extends AdminDetailsController
|
||||
{
|
||||
protected bool $debug = true;
|
||||
|
||||
protected string $host;
|
||||
|
||||
protected Net_SMTP $smtp;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
/** @var Shop $activeShop */
|
||||
$activeShop = Registry::getConfig()->getActiveShop();
|
||||
|
||||
$this->host = Registry::getRequest()->getRequestEscapedParameter('') ?? $activeShop->getFieldData('oxsmtp');
|
||||
|
||||
$this->checkDataAreSet();
|
||||
$this->hostIsAvailable();
|
||||
|
||||
/*
|
||||
//$host = 'cloud1-vm279.de-nserver.de:587';
|
||||
$from = 'mail@ds.data-develop.de';
|
||||
$rcpt = array('test@ds.data-develop.de', 'test@daniel-seifert.com', 'recipient2@example.com');
|
||||
//$rcpt = array('test@ds.data-develop.de');
|
||||
$rcpt = array('test@daniel-seifert.com');
|
||||
$subj = "Subject: Test Message\n";
|
||||
$body = "Body Line 1\nBody Line 2";
|
||||
|
||||
if ( PEAR::isError( $e = $smtp->connect())) {
|
||||
dumpvar(__METHOD__.__LINE__.PHP_EOL);
|
||||
die($e->getMessage() . "\n");
|
||||
}
|
||||
|
||||
if ( PEAR::isError( $smtp->mailFrom( $from))) {
|
||||
die("Unable to set sender to $from\n");
|
||||
}
|
||||
|
||||
foreach ($rcpt as $to) {
|
||||
dumpvar($to.PHP_EOL);
|
||||
if ( PEAR::isError( $res = $smtp->rcptTo( $to))) {
|
||||
die("Unable to add recipient $to: " . $res->getMessage() . "\n");
|
||||
}
|
||||
}
|
||||
|
||||
/* Set the body of the message. */
|
||||
/*
|
||||
if ( PEAR::isError( $res = $smtp->data( $subj . "\r\n" . $body))) {
|
||||
dumpvar($res->getMessage());
|
||||
die("Unable to send data\n");
|
||||
}
|
||||
|
||||
/* Disconnect from the SMTP server. */
|
||||
/*
|
||||
$smtp->disconnect();
|
||||
*/
|
||||
}
|
||||
|
||||
protected function checkDataAreSet()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws InvalidArgumentException
|
||||
* @return void
|
||||
*/
|
||||
protected function hostIsAvailable()
|
||||
{
|
||||
$this->host = 'test.example.dev';
|
||||
Assert::that(( $this->smtp = new Net_SMTP( $this->host ) ))->true('Unable to instantiate SMTP object');
|
||||
$this->smtp->setDebug($this->debug);
|
||||
}
|
||||
|
||||
protected function foo()
|
||||
{
|
||||
PEAR::isError( $e = $this->smtp->connect());
|
||||
dumpvar(get_class($e));
|
||||
die();
|
||||
Assert::that(PEAR::isError( $e = $this->smtp->connect()))->false($e->getMessage());
|
||||
{
|
||||
dumpvar(__METHOD__.__LINE__.PHP_EOL);
|
||||
die($e->getMessage() . "\n");
|
||||
}
|
||||
}
|
||||
}
|
@ -27,7 +27,8 @@
|
||||
"require": {
|
||||
"php": ">=7.3",
|
||||
"oxid-esales/oxideshop-ce": "6.8 - 6.14",
|
||||
"pear/net_smtp": "^1.11"
|
||||
"pear/net_smtp": "^1.11",
|
||||
"beberlei/assert": "^3.3"
|
||||
},
|
||||
"require-dev": {
|
||||
"php": "^7.4",
|
||||
@ -50,7 +51,7 @@
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"D3\\SMTPChecker\\": "../../../source/modules/d3/smtpchecker"
|
||||
"D3\\SmtpChecker\\": "../../../source/modules/d3/smtpchecker"
|
||||
}
|
||||
},
|
||||
"scripts": {
|
||||
|
8
menu.xml
Normal file
8
menu.xml
Normal file
@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<OX>
|
||||
<OXMENU id="NAVIGATION_ESHOPADMIN">
|
||||
<MAINMENU id="mxservice">
|
||||
<SUBMENU id="MXSMTPCHECKER" cl="d3smtpchecker" />
|
||||
</MAINMENU>
|
||||
</OXMENU>
|
||||
</OX>
|
@ -13,6 +13,8 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use D3\SmtpChecker\Application\Controller\Admin\SmtpChecker;
|
||||
|
||||
$sMetadataVersion = '2.1';
|
||||
|
||||
$sModuleId = 'd3smtpchecker';
|
||||
@ -34,7 +36,7 @@ $aModule = [
|
||||
'email' => 'support@shopmodule.com',
|
||||
'url' => 'https://www.oxidmodule.com/',
|
||||
'controllers' => [
|
||||
// 'd3ControllerAlias' => D3\ThisModule\Application\Controller\Admin\d3Controller::class,
|
||||
'd3smtpchecker' => SmtpChecker::class,
|
||||
],
|
||||
'extend' => [
|
||||
// \OxidEsales\Eshop\Core\ShopControl::class => \D3\ThisModule\Modules\Core\ShopControl_MyModule::class
|
||||
|
Loading…
Reference in New Issue
Block a user