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 attach(\Swift_Attachment $attachment) : self;
|
||||
|
||||
public function setTo($to) : self;
|
||||
}
|
||||
@@ -8,11 +8,15 @@ class SwiftMailer implements MailerInterface
|
||||
|
||||
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) {
|
||||
$this->emailConfiguration = $configuration;
|
||||
@@ -28,10 +32,24 @@ class SwiftMailer implements MailerInterface
|
||||
->setFrom( $this->from )
|
||||
->setTo( $this->to )
|
||||
->setCC($this->cc ?? [])
|
||||
->setBCC($this->bcc ?? [])
|
||||
->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);
|
||||
}
|
||||
|
||||
public function attach(\Swift_Attachment $attachment) : self
|
||||
{
|
||||
$this->attachments[] = $attachment;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setFrom(/*stringable|array*/ $from) : MailerInterface
|
||||
{
|
||||
@@ -54,4 +72,10 @@ class SwiftMailer implements MailerInterface
|
||||
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\RequestHandlerInterface;
|
||||
|
||||
use Zend\Diactoros\Response,
|
||||
Zend\Diactoros\ServerRequest,
|
||||
Zend\Diactoros\Stream,
|
||||
Zend\Diactoros\Uri;
|
||||
use Laminas\Diactoros\Response,
|
||||
Laminas\Diactoros\ServerRequest,
|
||||
Laminas\Diactoros\Stream,
|
||||
Laminas\Diactoros\Uri;
|
||||
|
||||
class JavascriptMiddleware implements MiddlewareInterface
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user