<?php
 use League\OAuth2\Client\Provider\AbstractProvider; abstract class vB_Mail_Transport { use vB_Trait_NoSerialize; private static array $classmap = [ 'gmail' => 'vB_Mail_Transport_PhpMailer_Gmail', 'microsoft' => 'vB_Mail_Transport_PhpMailer_Microsoft', 'smtp' => 'vB_Mail_Transport_PhpMailer_Smtp', 'phpmail' => 'vB_Mail_Transport_PhpMailer_PhpMail', 'legacysmtp' => 'vB_Mail_Transport_Legacy_Smtp', 'legacyphpmail' => 'vB_Mail_Transport_Legacy_PhpMail', ]; protected array $defaultSmtpPort = [ 'none' => 25, 'tls' => 587, 'ssl' => 465, ]; protected array $defaultHeaders = [ 'Auto-Submitted: auto-generated', ]; protected bool $isDebug = false; protected bool $isDataUtf8Encoded = false; private bool $isUtf8; private vB_Utility_String $stringutil; public static function registerTransport(string $type, string $class) : void { self::$classmap[$type] = $class; } public static function createDefault() : self { return self::create(strval(vB::getDatastore()->getOption('email_type'))); } public static function create(string $type) : self { if (!isset(self::$classmap[$type])) { throw new vB_Exception_Api('invalid_data_w_x_y_z', [$type, 'type', __CLASS__, __FUNCTION__]); } return new self::$classmap[$type]; } protected function __construct() { $this->stringutil = vB::getString(); $this->isUtf8 = $this->stringutil->isDefaultCharset('utf-8'); } abstract public function send(array|string $to, string $subject, string $message, bool $isHtml, array $headers, array|string $replyto = '') : bool; public function setDebug(bool $isDebug) : void { $this->isDebug = $isDebug; } public function setDataUtf8Encoded(bool $isUtf8) : void { $this->isDataUtf8Encoded = $isUtf8; } public function getDebugInfo() { return []; } public function startBatch() { } public function endBatch() { } protected function getSenderName() : string { $sitename = vB::getDatastore()->getOption('bbtitle'); $phrases = vB_Api::instanceInternal('phrase')->renderPhrases(['name' => ['x_mailer', $sitename]], 0); return $phrases['phrases']['name']; } protected function toUtf8(string $string) : string { if (!$this->isUtf8) { $string = $this->stringutil->toUtf8($string); } return $string; } } 