Fix remaining code review findings: email transport errors, metadata payload, from-name, pagination

- Email::send(): add curl_error() check so transport failures (timeout,
  DNS, TLS) return a diagnosable error string instead of Unknown error
- Email::send(): strip metadata key from options before array_merge so
  non-API fields are never sent to CyberMail endpoint
- Email::send() + sendEmail(): include from-name in From field using
  RFC 5322 "Name <email>" format so fromName DB setting takes effect
- email-log.php: replace unbounded page-link loop with a windowed
  paginator (first/last 2 pages + ±2 around current) with ellipsis
  gaps — prevents hundreds of anchors rendering at scale
This commit is contained in:
2026-06-03 06:01:44 +00:00
parent a5b91ca0ea
commit 7eddf9e85d
3 changed files with 32 additions and 8 deletions
+1 -1
View File
@@ -336,7 +336,7 @@ function sendEmail($to, $subject, $htmlContent, $textContent = '') {
error_log('[TJJ sendEmail] CYBERMAIL_API_KEY not configured');
return false;
}
$payload = ['from' => $from, 'to' => $to, 'subject' => $subject, 'html' => $htmlContent];
$payload = ['from' => $fromName . ' <' . $from . '>', 'to' => $to, 'subject' => $subject, 'html' => $htmlContent];
if ($textContent) $payload['text'] = $textContent;
$ch = curl_init('https://platform.cyberpersons.com/email/v1/send');
curl_setopt_array($ch, [