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 attach(\Swift_Attachment $attachment) : self;
|
||||
|
||||
public function setTo($to) : self;
|
||||
}
|
|
@ -16,6 +16,8 @@ class SwiftMailer implements MailerInterface
|
|||
|
||||
protected /*stringable|array*/ $bcc;
|
||||
|
||||
protected array $attachments = [];
|
||||
|
||||
public function __construct(EmailConfiguration $configuration) {
|
||||
$this->emailConfiguration = $configuration;
|
||||
|
||||
|
@ -33,9 +35,22 @@ class SwiftMailer implements MailerInterface
|
|||
->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
|
||||
{
|
||||
$this->from = $from;
|
||||
|
|
Loading…
Reference in New Issue