mirror of
http://124.126.16.154:8888/singularity/HyperfDevelopmentKitCore.git
synced 2026-01-15 05:55:12 +08:00
3
.gitignore
vendored
3
.gitignore
vendored
@@ -1,3 +1,4 @@
|
|||||||
vendor/
|
vendor/
|
||||||
.phpunit.result.cache
|
.phpunit.result.cache
|
||||||
.php-cs-fixer.cache
|
.php-cs-fixer.cache
|
||||||
|
runtime/
|
||||||
1
.idea/HDK-Core.iml
generated
1
.idea/HDK-Core.iml
generated
@@ -2,7 +2,6 @@
|
|||||||
<module type="WEB_MODULE" version="4">
|
<module type="WEB_MODULE" version="4">
|
||||||
<component name="NewModuleRootManager">
|
<component name="NewModuleRootManager">
|
||||||
<content url="file://$MODULE_DIR$">
|
<content url="file://$MODULE_DIR$">
|
||||||
<sourceFolder url="file://$MODULE_DIR$/spec" isTestSource="true" />
|
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" packagePrefix="Singularity\HDK\Core\" />
|
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" packagePrefix="Singularity\HDK\Core\" />
|
||||||
<sourceFolder url="file://$MODULE_DIR$/tests" isTestSource="true" packagePrefix="Singularity\HDK\Test\Core\" />
|
<sourceFolder url="file://$MODULE_DIR$/tests" isTestSource="true" packagePrefix="Singularity\HDK\Test\Core\" />
|
||||||
<excludeFolder url="file://$MODULE_DIR$/vendor/sebastian/recursion-context" />
|
<excludeFolder url="file://$MODULE_DIR$/vendor/sebastian/recursion-context" />
|
||||||
|
|||||||
24
.idea/php-docker-settings.xml
generated
Normal file
24
.idea/php-docker-settings.xml
generated
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="PhpDockerContainerSettings">
|
||||||
|
<list>
|
||||||
|
<map>
|
||||||
|
<entry key="9fb85f67-19fd-423f-9358-1b155a12eb7d">
|
||||||
|
<value>
|
||||||
|
<DockerContainerSettings>
|
||||||
|
<option name="version" value="1" />
|
||||||
|
<option name="volumeBindings">
|
||||||
|
<list>
|
||||||
|
<DockerVolumeBindingImpl>
|
||||||
|
<option name="containerPath" value="/opt/project" />
|
||||||
|
<option name="hostPath" value="$PROJECT_DIR$" />
|
||||||
|
</DockerVolumeBindingImpl>
|
||||||
|
</list>
|
||||||
|
</option>
|
||||||
|
</DockerContainerSettings>
|
||||||
|
</value>
|
||||||
|
</entry>
|
||||||
|
</map>
|
||||||
|
</list>
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
@@ -41,6 +41,11 @@ class EmailWillSent
|
|||||||
*/
|
*/
|
||||||
public array $cc = [];
|
public array $cc = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string[] $bcc
|
||||||
|
*/
|
||||||
|
public array $bcc = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var string 'text'|'html' $type
|
* @var string 'text'|'html' $type
|
||||||
*/
|
*/
|
||||||
@@ -58,12 +63,14 @@ class EmailWillSent
|
|||||||
* @var non-empty-string[] $cc
|
* @var non-empty-string[] $cc
|
||||||
*/
|
*/
|
||||||
array $cc = [],
|
array $cc = [],
|
||||||
string $type = 'text'
|
string $type = 'text',
|
||||||
|
array $bcc = []
|
||||||
) {
|
) {
|
||||||
$this->type = $type;
|
$this->type = $type;
|
||||||
$this->cc = $cc;
|
$this->cc = $cc;
|
||||||
$this->content = $content;
|
$this->content = $content;
|
||||||
$this->subject = $subject;
|
$this->subject = $subject;
|
||||||
$this->target = $target;
|
$this->target = $target;
|
||||||
|
$this->bcc = $bcc;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,11 +9,7 @@
|
|||||||
|
|
||||||
namespace Singularity\HDK\Core\Listener;
|
namespace Singularity\HDK\Core\Listener;
|
||||||
|
|
||||||
use Hyperf\Contract\ContainerInterface;
|
|
||||||
use Hyperf\Contract\StdoutLoggerInterface;
|
use Hyperf\Contract\StdoutLoggerInterface;
|
||||||
use Hyperf\Di\Annotation\Inject;
|
|
||||||
use Hyperf\Event\Contract\ListenerInterface;
|
|
||||||
use JetBrains\PhpStorm\NoReturn;
|
|
||||||
use Psr\Container\ContainerExceptionInterface;
|
use Psr\Container\ContainerExceptionInterface;
|
||||||
use Psr\Container\NotFoundExceptionInterface;
|
use Psr\Container\NotFoundExceptionInterface;
|
||||||
use Singularity\HDK\Core\Constants\CommonErrorCode;
|
use Singularity\HDK\Core\Constants\CommonErrorCode;
|
||||||
@@ -43,7 +39,8 @@ class EmailWillSentListener extends AbstractListener
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param EmailWillSent $event
|
* @param object $event
|
||||||
|
*
|
||||||
* @return void
|
* @return void
|
||||||
* @throws ContainerExceptionInterface
|
* @throws ContainerExceptionInterface
|
||||||
* @throws NotFoundExceptionInterface
|
* @throws NotFoundExceptionInterface
|
||||||
@@ -53,18 +50,21 @@ class EmailWillSentListener extends AbstractListener
|
|||||||
$stdoutLogger = $this->container->get(StdoutLoggerInterface::class);
|
$stdoutLogger = $this->container->get(StdoutLoggerInterface::class);
|
||||||
$emailService = $this->container->get(EmailService::class);
|
$emailService = $this->container->get(EmailService::class);
|
||||||
try {
|
try {
|
||||||
|
/** @var $event EmailWillSent */
|
||||||
$event->type === 'html'
|
$event->type === 'html'
|
||||||
? $emailService->sendHtml(
|
? $emailService->sendHtml(
|
||||||
$event->target,
|
$event->target,
|
||||||
$event->subject,
|
$event->subject,
|
||||||
$event->content,
|
$event->content,
|
||||||
$event->cc
|
$event->cc,
|
||||||
|
$event->bcc,
|
||||||
)
|
)
|
||||||
: $emailService->sendText(
|
: $emailService->sendText(
|
||||||
$event->target,
|
$event->target,
|
||||||
$event->subject,
|
$event->subject,
|
||||||
$event->content,
|
$event->content,
|
||||||
$event->cc
|
$event->cc,
|
||||||
|
$event->bcc,
|
||||||
);
|
);
|
||||||
|
|
||||||
$stdoutLogger->info('邮件发送成功!');
|
$stdoutLogger->info('邮件发送成功!');
|
||||||
|
|||||||
@@ -66,9 +66,10 @@ class EmailService
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string|array<string> $target
|
* @param string|array<string> $target
|
||||||
* @param string $subject
|
* @param string $subject
|
||||||
* @param string $text
|
* @param string $text
|
||||||
* @param array<string> $cc
|
* @param array<string> $cc
|
||||||
|
* @param array $bcc
|
||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
* @throws TransportExceptionInterface
|
* @throws TransportExceptionInterface
|
||||||
@@ -77,12 +78,14 @@ class EmailService
|
|||||||
$target,
|
$target,
|
||||||
string $subject,
|
string $subject,
|
||||||
string $text,
|
string $text,
|
||||||
array $cc = []
|
array $cc = [],
|
||||||
|
array $bcc = []
|
||||||
): bool {
|
): bool {
|
||||||
$email = (new Email())
|
$email = (new Email())
|
||||||
->from(Address::create($this->from))
|
->from(Address::create($this->from))
|
||||||
->to(...(is_array($target) ? $target : [$target]))
|
->to(...(is_array($target) ? $target : [$target]))
|
||||||
->cc(...$cc)
|
->cc(...$cc)
|
||||||
|
->bcc(...$bcc)
|
||||||
->subject($subject)
|
->subject($subject)
|
||||||
->text($text);
|
->text($text);
|
||||||
|
|
||||||
@@ -95,9 +98,10 @@ class EmailService
|
|||||||
* 以 HTML 格式发送邮件
|
* 以 HTML 格式发送邮件
|
||||||
*
|
*
|
||||||
* @param string|array<string> $target
|
* @param string|array<string> $target
|
||||||
* @param string $subject
|
* @param string $subject
|
||||||
* @param string $html
|
* @param string $html
|
||||||
* @param array<string> $cc
|
* @param array<string> $cc
|
||||||
|
* @param array $bcc
|
||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
* @throws TransportExceptionInterface
|
* @throws TransportExceptionInterface
|
||||||
@@ -106,12 +110,14 @@ class EmailService
|
|||||||
$target,
|
$target,
|
||||||
string $subject,
|
string $subject,
|
||||||
string $html,
|
string $html,
|
||||||
array $cc = []
|
array $cc = [],
|
||||||
|
array $bcc = []
|
||||||
): bool {
|
): bool {
|
||||||
$email = (new Email())
|
$email = (new Email())
|
||||||
->from(Address::create($this->from))
|
->from(Address::create($this->from))
|
||||||
->to(...(is_array($target) ? $target : [$target]))
|
->to(...(is_array($target) ? $target : [$target]))
|
||||||
->cc(...$cc)
|
->cc(...$cc)
|
||||||
|
->bcc(...$bcc)
|
||||||
->subject($subject)
|
->subject($subject)
|
||||||
->html($html);
|
->html($html);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user