/* Decoded by unphp.net */ get_text("Sending email %d to %d recipients"), self::MSG_RECIPIENT => get_text("%s"), self::MSG_HANDLER => get_text("Using message handler %s"), self::MSG_GENERATE => get_text("Generating message"), self::MSG_SENT => get_text("Message sent"), self::ERR_MISSING_ID => get_text("Missing email ID parameter"), self::ERR_UNKNOWN_ID => get_text("Unknown email ID %d"), self::ERR_SEND => get_text("Error sending email: %s"), self::ERR_HANDLER => get_text("Handler class not found")]; } public function run($param) : bool { if (empty($param["id"])) { return $this->logError(self::ERR_MISSING_ID); } $emailDb = new MailDb(); $email = $emailDb->findById($param["id"]); if ($email === false) { return $this->logError(self::ERR_UNKNOWN_ID, $param["id"]); } $this->logInfo(self::MSG_SEND, $email["id"], count($email["recipient"])); $this->logPush(); foreach ($email["recipient"] as $recipient) { $this->logInfo(self::MSG_RECIPIENT, $recipient["email"]); } $this->logPop(); if (empty($email["messageHandler"])) { $messageHandler = "\VDV\Core\Model\MailMessage"; } else { $this->logInfo(self::MSG_HANDLER, $email["messageHandler"]); $messageHandler = $email["messageHandler"]; } if (!class_exists($messageHandler)) { return $this->logError(self::ERR_HANDLER); } $attachments = []; $emailSent = false; $mail = new PHPMailer(); try { $this->logInfo(self::MSG_GENERATE); $mailSettings = $emailDb->mailSettings(); $mail->IsSMTP(); $mail->SMTPDebug = $param["debug"] ?? 0; $mail->SMTPAuth = !empty($mailSettings["mail_server_user"]) && !empty($mailSettings["mail_server_password"]); $mail->Host = $mailSettings["mail_server"]; $mail->Port = $mailSettings["email_port"]; $mail->Username = $mailSettings["mail_server_user"]; $mail->Password = $mailSettings["mail_server_password"]; $mail->CharSet = "UTF-8"; $mail->Encoding = "base64"; if ($mailSettings["email_ssl"] == 1) { $mail->SMTPSecure = "ssl"; } if ($mailSettings["email_ssl"] == 2) { $mail->SMTPSecure = "tsl"; } if ($mailSettings["email_ssl_disable_verify"] == 1) { $mail->SMTPOptions = ["ssl" => ["verify_peer" => false, "verify_peer_name" => false, "allow_self_signed" => true]]; } $mail->SetFrom($mailSettings["return_address"], $mailSettings["return_address_name"]); $mail->AddReplyTo($mailSettings["return_address"], $mailSettings["return_address_name"]); $handler = new $messageHandler($email); $mail->Subject = $handler->subject(); $mail->MsgHTML($handler->htmlBody()); foreach ($handler->recipients() as $recipient) { $mail->AddAddress($recipient["email"], ''); } $attachments = $handler->attachments(); foreach ($attachments as $attachment) { $mail->AddAttachment($attachment); } foreach ($email["attachment"] as $attachment) { $mail->AddAttachment($attachment["path"], $attachment["name"]); } $emailSent = $mail->Send(); if ($emailSent === false) { $this->logError(self::ERR_SEND, $mail->ErrorInfo); } else { $this->logInfo(self::MSG_SENT); } } catch (Exception $e) { $this->logError(self::ERR_SEND, !empty($mail->ErrorInfo) ? $mail->ErrorInfo : $e->getMessage()); } $emailDb->updateStatus($email["id"], $emailSent ? MailDb::STATUS_SENT : MailDb::STATUS_FAILED); foreach ($attachments as $attachment) { unlink($attachment); } return $emailSent; } } ?>