Bugfixes made on the interface
This commit is contained in:
parent
bee7e25935
commit
34b850c780
|
@ -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;
|
||||||
}
|
}
|
|
@ -15,6 +15,8 @@ class SwiftMailer implements MailerInterface
|
||||||
protected /*stringable|array*/ $cc;
|
protected /*stringable|array*/ $cc;
|
||||||
|
|
||||||
protected /*stringable|array*/ $bcc;
|
protected /*stringable|array*/ $bcc;
|
||||||
|
|
||||||
|
protected array $attachments = [];
|
||||||
|
|
||||||
public function __construct(EmailConfiguration $configuration) {
|
public function __construct(EmailConfiguration $configuration) {
|
||||||
$this->emailConfiguration = $configuration;
|
$this->emailConfiguration = $configuration;
|
||||||
|
@ -32,9 +34,22 @@ class SwiftMailer implements MailerInterface
|
||||||
->setCC($this->cc ?? [])
|
->setCC($this->cc ?? [])
|
||||||
->setBCC($this->bcc ?? [])
|
->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
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue