new AlibabaCloud(), 'mailchimp' => new Mailchimp(), 'mailgun' => new Mailgun(), 'postal' => new Postal(), 'sendgrid' => new SendGrid(), 'ses' => new Ses(), 'smtp' => new Smtp(), default => new NullMail(), }; } /** * @throws Exception */ public static function genHtml($template, $ary): false|string { $smarty = new Smarty(); $smarty->setTemplateDir(BASE_PATH . '/resources/email/'); $smarty->setCompileDir(BASE_PATH . '/storage/framework/smarty/compile/'); $smarty->setCacheDir(BASE_PATH . '/storage/framework/smarty/cache/'); $smarty->assign('config', View::getConfig()); foreach ($ary as $key => $value) { $smarty->assign($key, $value); } return $smarty->fetch($template); } /** * @throws Exception * @throws ClientExceptionInterface */ public static function send($to, $subject, $template, $array = []): void { $body = self::genHtml($template, $array); self::getClient()->send($to, $subject, $body); } }