Fix serialization error when sending email by SMTP in background task

https://xetown.com/questions/1842571
This commit is contained in:
Kijin Sung 2024-10-25 01:46:42 +09:00
parent 9e1772285a
commit 8473eeabc3
2 changed files with 30 additions and 27 deletions

View file

@ -7,15 +7,6 @@ namespace Rhymix\Framework\Drivers\Mail;
*/
class MailFunction extends Base implements \Rhymix\Framework\Drivers\MailInterface
{
/**
* Direct invocation of the constructor is not permitted.
*/
protected function __construct()
{
include_once \RX_BASEDIR . 'common/libraries/swift_mail.php';
$this->_mailer = new \Swift_Mailer(new \Swift_MailTransport);
}
/**
* Get the human-readable name of this mail driver.
*
@ -58,6 +49,12 @@ class MailFunction extends Base implements \Rhymix\Framework\Drivers\MailInterfa
*/
public function send(\Rhymix\Framework\Mail $message)
{
if ($this->_mailer === null)
{
include_once \RX_BASEDIR . 'common/libraries/swift_mail.php';
$this->_mailer = new \Swift_Mailer(new \Swift_MailTransport);
}
try
{
$errors = [];