Compare commits
3
Commits
dev
..
1e7ac5db47
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1e7ac5db47 | ||
|
|
34b850c780 | ||
|
|
bee7e25935 |
No files matched your search
@@ -8,5 +8,7 @@ interface MailerInterface
|
|||||||
|
|
||||||
public function setFrom($from) : self;
|
public function setFrom($from) : self;
|
||||||
|
|
||||||
|
public function attach(\Swift_Attachment $attachment) : self;
|
||||||
|
|
||||||
public function setTo($to) : self;
|
public function setTo($to) : self;
|
||||||
}
|
}
|
||||||
@@ -8,11 +8,15 @@ class SwiftMailer implements MailerInterface
|
|||||||
|
|
||||||
protected $transport;
|
protected $transport;
|
||||||
|
|
||||||
protected $from;
|
protected /*stringable*/ $from;
|
||||||
|
|
||||||
protected $to;
|
protected /*stringable|array*/ $to;
|
||||||
|
|
||||||
protected $cc;
|
protected /*stringable|array*/ $cc;
|
||||||
|
|
||||||
|
protected /*stringable|array*/ $bcc;
|
||||||
|
|
||||||
|
protected array $attachments = [];
|
||||||
|
|
||||||
public function __construct(EmailConfiguration $configuration) {
|
public function __construct(EmailConfiguration $configuration) {
|
||||||
$this->emailConfiguration = $configuration;
|
$this->emailConfiguration = $configuration;
|
||||||
@@ -28,10 +32,24 @@ class SwiftMailer implements MailerInterface
|
|||||||
->setFrom( $this->from )
|
->setFrom( $this->from )
|
||||||
->setTo( $this->to )
|
->setTo( $this->to )
|
||||||
->setCC($this->cc ?? [])
|
->setCC($this->cc ?? [])
|
||||||
|
->setBCC($this->bcc ?? [])
|
||||||
->setBody( $message, $html ? 'text/html' : 'text/plain' );
|
->setBody( $message, $html ? 'text/html' : 'text/plain' );
|
||||||
|
|
||||||
|
foreach ($this->attachments as $attachment) {
|
||||||
|
$swiftObj->attach($attachment);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->attachments = [];
|
||||||
|
|
||||||
return ( new \Swift_Mailer($this->transport) )->send($swiftObj);
|
return ( new \Swift_Mailer($this->transport) )->send($swiftObj);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function attach(\Swift_Attachment $attachment) : self
|
||||||
|
{
|
||||||
|
$this->attachments[] = $attachment;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
public function setFrom(/*stringable|array*/ $from) : MailerInterface
|
public function setFrom(/*stringable|array*/ $from) : MailerInterface
|
||||||
{
|
{
|
||||||
@@ -54,4 +72,10 @@ class SwiftMailer implements MailerInterface
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function setBCC(/*stringable|array*/ $bcc) : MailerInterface
|
||||||
|
{
|
||||||
|
$this->bcc = $bcc;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -9,10 +9,10 @@ use Psr\Http\Message\ResponseFactoryInterface,
|
|||||||
Psr\Http\Server\MiddlewareInterface,
|
Psr\Http\Server\MiddlewareInterface,
|
||||||
Psr\Http\Server\RequestHandlerInterface;
|
Psr\Http\Server\RequestHandlerInterface;
|
||||||
|
|
||||||
use Zend\Diactoros\Response,
|
use Laminas\Diactoros\Response,
|
||||||
Zend\Diactoros\ServerRequest,
|
Laminas\Diactoros\ServerRequest,
|
||||||
Zend\Diactoros\Stream,
|
Laminas\Diactoros\Stream,
|
||||||
Zend\Diactoros\Uri;
|
Laminas\Diactoros\Uri;
|
||||||
|
|
||||||
class JavascriptMiddleware implements MiddlewareInterface
|
class JavascriptMiddleware implements MiddlewareInterface
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in new issue
Block a user