mirror of
http://124.126.16.154:8888/singularity/HyperfDevelopmentKitCore.git
synced 2026-01-15 06:15:10 +08:00
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,3 +1,4 @@
|
||||
vendor/
|
||||
.phpunit.result.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">
|
||||
<component name="NewModuleRootManager">
|
||||
<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$/tests" isTestSource="true" packagePrefix="Singularity\HDK\Test\Core\" />
|
||||
<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 = [];
|
||||
|
||||
/**
|
||||
* @var string[] $bcc
|
||||
*/
|
||||
public array $bcc = [];
|
||||
|
||||
/**
|
||||
* @var string 'text'|'html' $type
|
||||
*/
|
||||
@@ -58,12 +63,14 @@ class EmailWillSent
|
||||
* @var non-empty-string[] $cc
|
||||
*/
|
||||
array $cc = [],
|
||||
string $type = 'text'
|
||||
string $type = 'text',
|
||||
array $bcc = []
|
||||
) {
|
||||
$this->type = $type;
|
||||
$this->cc = $cc;
|
||||
$this->content = $content;
|
||||
$this->subject = $subject;
|
||||
$this->target = $target;
|
||||
$this->bcc = $bcc;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,11 +9,7 @@
|
||||
|
||||
namespace Singularity\HDK\Core\Listener;
|
||||
|
||||
use Hyperf\Contract\ContainerInterface;
|
||||
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\NotFoundExceptionInterface;
|
||||
use Singularity\HDK\Core\Constants\CommonErrorCode;
|
||||
@@ -43,7 +39,8 @@ class EmailWillSentListener extends AbstractListener
|
||||
}
|
||||
|
||||
/**
|
||||
* @param EmailWillSent $event
|
||||
* @param object $event
|
||||
*
|
||||
* @return void
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
@@ -53,18 +50,21 @@ class EmailWillSentListener extends AbstractListener
|
||||
$stdoutLogger = $this->container->get(StdoutLoggerInterface::class);
|
||||
$emailService = $this->container->get(EmailService::class);
|
||||
try {
|
||||
/** @var $event EmailWillSent */
|
||||
$event->type === 'html'
|
||||
? $emailService->sendHtml(
|
||||
$event->target,
|
||||
$event->subject,
|
||||
$event->content,
|
||||
$event->cc
|
||||
$event->cc,
|
||||
$event->bcc,
|
||||
)
|
||||
: $emailService->sendText(
|
||||
$event->target,
|
||||
$event->subject,
|
||||
$event->content,
|
||||
$event->cc
|
||||
$event->cc,
|
||||
$event->bcc,
|
||||
);
|
||||
|
||||
$stdoutLogger->info('邮件发送成功!');
|
||||
|
||||
@@ -66,9 +66,10 @@ class EmailService
|
||||
|
||||
/**
|
||||
* @param string|array<string> $target
|
||||
* @param string $subject
|
||||
* @param string $text
|
||||
* @param string $subject
|
||||
* @param string $text
|
||||
* @param array<string> $cc
|
||||
* @param array $bcc
|
||||
*
|
||||
* @return bool
|
||||
* @throws TransportExceptionInterface
|
||||
@@ -77,12 +78,14 @@ class EmailService
|
||||
$target,
|
||||
string $subject,
|
||||
string $text,
|
||||
array $cc = []
|
||||
array $cc = [],
|
||||
array $bcc = []
|
||||
): bool {
|
||||
$email = (new Email())
|
||||
->from(Address::create($this->from))
|
||||
->to(...(is_array($target) ? $target : [$target]))
|
||||
->cc(...$cc)
|
||||
->bcc(...$bcc)
|
||||
->subject($subject)
|
||||
->text($text);
|
||||
|
||||
@@ -95,9 +98,10 @@ class EmailService
|
||||
* 以 HTML 格式发送邮件
|
||||
*
|
||||
* @param string|array<string> $target
|
||||
* @param string $subject
|
||||
* @param string $html
|
||||
* @param string $subject
|
||||
* @param string $html
|
||||
* @param array<string> $cc
|
||||
* @param array $bcc
|
||||
*
|
||||
* @return bool
|
||||
* @throws TransportExceptionInterface
|
||||
@@ -106,12 +110,14 @@ class EmailService
|
||||
$target,
|
||||
string $subject,
|
||||
string $html,
|
||||
array $cc = []
|
||||
array $cc = [],
|
||||
array $bcc = []
|
||||
): bool {
|
||||
$email = (new Email())
|
||||
->from(Address::create($this->from))
|
||||
->to(...(is_array($target) ? $target : [$target]))
|
||||
->cc(...$cc)
|
||||
->bcc(...$bcc)
|
||||
->subject($subject)
|
||||
->html($html);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user