Fix SMTP connection in Docker with IPv4 force, and prevent attempts from incrementing on mail failure

This commit is contained in:
ilham_gmail
2026-06-11 21:27:58 +07:00
parent 3d281d570e
commit 1e0044c260
2 changed files with 17 additions and 5 deletions
+10 -1
View File
@@ -34,12 +34,21 @@ function send_mail_phpmailer($to, $subject, $body, $isHtml = false){
if($smtpHost){
$mail->isSMTP();
$mail->Host = $smtpHost;
$mail->Host = gethostbyname($smtpHost); // Force IPv4
$mail->SMTPAuth = true;
$mail->Username = $smtpUser;
$mail->Password = $smtpPass;
$mail->Port = intval($smtpPort);
// Bypass SSL verification issues with IP hostname in Docker
$mail->SMTPOptions = array(
'ssl' => array(
'verify_peer' => false,
'verify_peer_name' => false,
'allow_self_signed' => true
)
);
if(strtolower($smtpEnc) === 'ssl'){
$mail->SMTPSecure = PHPMailer::ENCRYPTION_SMTPS;
} elseif(strtolower($smtpEnc) === 'tls'){