Upgrade to 3.4.1
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace Kirby\Email;
|
||||
|
||||
use Closure;
|
||||
use Exception;
|
||||
use Kirby\Toolkit\Properties;
|
||||
use Kirby\Toolkit\V;
|
||||
@@ -23,6 +24,7 @@ class Email
|
||||
protected $attachments;
|
||||
protected $body;
|
||||
protected $bcc;
|
||||
protected $beforeSend;
|
||||
protected $cc;
|
||||
protected $from;
|
||||
protected $fromName;
|
||||
@@ -60,6 +62,11 @@ class Email
|
||||
return $this->bcc;
|
||||
}
|
||||
|
||||
public function beforeSend(): ?Closure
|
||||
{
|
||||
return $this->beforeSend;
|
||||
}
|
||||
|
||||
public function cc(): array
|
||||
{
|
||||
return $this->cc;
|
||||
@@ -159,6 +166,12 @@ class Email
|
||||
return $this;
|
||||
}
|
||||
|
||||
protected function setBeforeSend(?Closure $beforeSend = null)
|
||||
{
|
||||
$this->beforeSend = $beforeSend;
|
||||
return $this;
|
||||
}
|
||||
|
||||
protected function setCc($cc = null)
|
||||
{
|
||||
$this->cc = $this->resolveEmail($cc);
|
||||
|
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace Kirby\Email;
|
||||
|
||||
use Kirby\Exception\InvalidArgumentException;
|
||||
use PHPMailer\PHPMailer\PHPMailer as Mailer;
|
||||
|
||||
/**
|
||||
@@ -67,6 +68,17 @@ class PHPMailer extends Email
|
||||
$mailer->Port = $this->transport()['port'] ?? null;
|
||||
}
|
||||
|
||||
// accessible phpMailer instance
|
||||
$beforeSend = $this->beforeSend();
|
||||
|
||||
if (empty($beforeSend) === false && is_a($beforeSend, 'Closure') === true) {
|
||||
$mailer = $beforeSend->call($this, $mailer) ?? $mailer;
|
||||
|
||||
if (is_a($mailer, 'PHPMailer\PHPMailer\PHPMailer') === false) {
|
||||
throw new InvalidArgumentException('"beforeSend" option return should be instance of PHPMailer\PHPMailer\PHPMailer class');
|
||||
}
|
||||
}
|
||||
|
||||
if ($debug === true) {
|
||||
return $this->isSent = true;
|
||||
}
|
||||
|
Reference in New Issue
Block a user