| Server IP : 104.21.21.239 / Your IP : 216.73.216.11 Web Server : Apache/2.4.68 (Amazon Linux) OpenSSL/3.5.5 System : Linux ip-172-31-69-123.ec2.internal 6.1.176-223.369.amzn2023.x86_64 #1 SMP PREEMPT_DYNAMIC Fri Jul 24 13:34:27 UTC 2026 x86_64 User : ec2-user ( 1000) PHP Version : 8.4.23 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /home/tgnewdev/admin/classes/lib/ |
Upload File : |
<?php
namespace classes\lib;
class EmailEngine {
public const AUTO_POPULATE_FIELDS = [
'' => 'None',
'last_name' => 'Last Name',
'first_name' => 'First Name',
'combined_name' => 'Combined First and Last Name',
'title' => 'Title',
'org' => 'Hotel/Company',
'email' => 'Email',
];
public const PLACEHOLDERS = [
'last_name' => 'Last Name',
'first_name' => 'First Name',
'title' => 'Title',
'venue_name' => 'Venue',
'email' => 'Email',
'office_phone' => 'Office Phone',
'cell_phone' => 'Cell Phone',
'other_phone' => 'Other Phone',
'form_link' => 'Form Link - start tag',
'/form_link' => 'Form Link - end tag',
];
public static function copy_template(int $source_template_id): int {
global $db;
try {
$db->beginTransaction();
$sql = "
INSERT INTO email_templates (
description,
html,
subject,
reply_name,
reply_address,
cc,
bcc,
create_date,
update_date,
create_by,
update_by
)
SELECT
CONCAT(description, ' - COPY'),
html,
subject,
reply_name,
reply_address,
cc,
bcc,
NOW(),
NOW(),
:user_id,
:user_id
FROM email_templates WHERE id = :id
";
$stmt_update = $db->prepare($sql);
$stmt_update->execute([
':id' => $source_template_id,
':user_id' => trim($_SESSION['user_id']),
]);
$new_template_id = last_id();
$db->commit();
} catch(\Exception $e) {
db_err_rollback($e);
}
return $new_template_id;
}
public static function add_to_queue($job_id, $subject, $to, $cc, $bcc, $body, $attachments = [], $replacements = [], $from = APP_MAIL_FROM, $reply_name = '', $reply_address = '') {
global $db;
$queue_data = [
'subject' => $subject,
'to' => $to,
'cc' => $cc,
'bcc' => $bcc,
'body' => $body,
'attachments' => $attachments,
'replacements' => $replacements,
'from' => $from,
'reply_name' => $reply_name,
'reply_address' => $reply_address,
];
$json = json_encode($queue_data);
try {
$db->beginTransaction();
$sql = "
INSERT INTO mail_queue SET
time_added = NOW(),
job_id = :job_id,
parameter_json = :json,
create_by = :user_id
";
$stmt_update = $db->prepare($sql);
$stmt_update->execute([
':job_id' => $job_id,
':json' => $json,
':user_id' => nz($_SESSION['user_id'], '0'),
]);
$db->commit();
} catch(\Exception $e) {
db_err_rollback($e);
}
}
public static function update_queue_item(int $queue_id, string $output = ''): void {
global $db;
try {
$db->beginTransaction();
$sql = "
UPDATE mail_queue SET
time_processed = NOW(),
output = :output
WHERE id = :queue_id
";
$stmt_update = $db->prepare($sql);
$stmt_update->execute([
':queue_id' => $queue_id,
':output' => $output,
]);
$db->commit();
} catch(\Exception $e) {
db_err_rollback($e);
}
}
}