PATH:
home
/
u865795251
/
domains
/
whatisnewis.com
/
public_html
/
vfa
/
Editing: mail-helper.php
<?php // Simple Mailer class utilizing SMTP sockets (TLS/SSL supported) class SimpleMailer { public static function send($to, $subject, $htmlMessage) { $host = SMTP_HOST; $port = SMTP_PORT; $username = SMTP_USER; $password = SMTP_PASS; $from = EMAIL_FROM; // Extract email address $fromEmail = $username; if (preg_match('/<([^>]+)>/', $from, $matches)) { $fromEmail = $matches[1]; } // Mock mail dispatch if SMTP not configured if (empty($username) || empty($password) || $password === 'YOUR_SMTP_PASS') { error_log("📬 [EMAIL MOCK]: SMTP not configured. Mocking email to $to"); return true; } try { $socket = @fsockopen(($port == 465 ? "ssl://" : "") . $host, $port, $errno, $errstr, 15); if (!$socket) { throw new Exception("Could not connect to SMTP server: $errstr ($errno)"); } self::getResponse($socket, "220"); fwrite($socket, "EHLO " . $_SERVER['SERVER_NAME'] . "\r\n"); self::getResponse($socket, "250"); if ($port == 587) { fwrite($socket, "STARTTLS\r\n"); self::getResponse($socket, "220"); if (!stream_socket_enable_crypto($socket, true, STREAM_CRYPTO_METHOD_TLS_CLIENT)) { throw new Exception("STARTTLS negotiation failed"); } fwrite($socket, "EHLO " . $_SERVER['SERVER_NAME'] . "\r\n"); self::getResponse($socket, "250"); } fwrite($socket, "AUTH LOGIN\r\n"); self::getResponse($socket, "334"); fwrite($socket, base64_encode($username) . "\r\n"); self::getResponse($socket, "334"); fwrite($socket, base64_encode($password) . "\r\n"); self::getResponse($socket, "235"); fwrite($socket, "MAIL FROM: <$fromEmail>\r\n"); self::getResponse($socket, "250"); fwrite($socket, "RCPT TO: <$to>\r\n"); self::getResponse($socket, "250"); fwrite($socket, "DATA\r\n"); self::getResponse($socket, "354"); // MIME standards $headers = "MIME-Version: 1.0\r\n"; $headers .= "Content-type: text/html; charset=utf-8\r\n"; $headers .= "To: <$to>\r\n"; $headers .= "From: $from\r\n"; $headers .= "Subject: =?UTF-8?B?" . base64_encode($subject) . "?=\r\n"; $headers .= "Date: " . date("r") . "\r\n"; $headers .= "Message-ID: <" . md5(uniqid(microtime(), true)) . "@" . $host . ">\r\n\r\n"; fwrite($socket, $headers . $htmlMessage . "\r\n.\r\n"); self::getResponse($socket, "250"); fwrite($socket, "QUIT\r\n"); fclose($socket); return true; } catch (Exception $e) { error_log("❌ SMTP Error sending to $to: " . $e->getMessage()); return false; } } private static function getResponse($socket, $expectedCode) { $response = ""; while ($line = fgets($socket, 512)) { $response .= $line; if (substr($line, 3, 1) == " ") break; } $code = substr($response, 0, 3); if ($code !== $expectedCode) { throw new Exception("SMTP protocol violation: expected $expectedCode, got response: $response"); } } } // Mail automation dispatcher function sendVerificationEmails($user) { $toUser = $user['email']; $subjectUser = "Webinar Registration Confirmed! - VFA Academy"; $whatsAppLink = WHATSAPP_LINK; // User HTML email template $htmlUser = " <div style='background-color: #0a0e17; color: #ffffff; padding: 40px; font-family: sans-serif; max-width: 600px; margin: 0 auto; border-radius: 8px; border: 1px solid #1a2233;'> <div style='text-align: center; border-bottom: 1px solid #1a2233; padding-bottom: 20px; margin-bottom: 30px;'> <h1 style='color: #ffffff; font-size: 26px; margin: 0;'>VFA <span style='color: #00e676;'>ACADEMY</span></h1> </div> <h2 style='color: #00e676;'>Hello " . htmlspecialchars($user['name']) . ",</h2> <p style='color: #8892b0; font-size: 15px; line-height: 1.6;'>Congratulations! Your seat has been reserved for our premium VFA Trading Webinar.</p> <div style='background: rgba(255,255,255,0.02); border: 1px solid #1a2233; padding: 20px; border-radius: 6px; margin: 25px 0;'> <h3 style='margin: 0 0 12px; color: #ffffff; font-size: 16px;'>Webinar Session Details</h3> <p style='margin: 5px 0; font-size: 14px; color: #8892b0;'>📅 <strong>Date:</strong> 31st May 2026 Sunday </p> <p style='margin: 5px 0; font-size: 14px; color: #8892b0;'>⏰ <strong>Time:</strong> 12:00 PM IST</p> <p style='margin: 5px 0; font-size: 14px; color: #8892b0;'>📍 <strong>Access Link:</strong> Shared in Community Group</p> </div> <p style='color: #8892b0; font-size: 15px;'>👉 To receive real-time charts, daily trading updates, and your direct Zoom link access, please join our private Trading Community instantly:</p> <div style='text-align: center; margin: 35px 0 20px;'> <a href='$whatsAppLink' style='background: linear-gradient(135deg, #25D366, #128C7E); color: white; padding: 14px 28px; text-decoration: none; border-radius: 6px; font-weight: bold; font-size: 16px; box-shadow: 0 4px 15px rgba(37,211,102,0.25); display: inline-block;'>Join Private WhatsApp Community</a> </div> <div style='border-top: 1px solid #1a2233; padding-top: 20px; margin-top: 40px; font-size: 12px; color: #8892b0; text-align: center;'> © " . date('Y') . " VFA Academy. All rights reserved. Support: info@vfaacademy.com </div> </div>"; // Dispatch to student SimpleMailer::send($toUser, $subjectUser, $htmlUser); // Admin HTML alert template $toAdmin = SMTP_USER; if (!empty($toAdmin)) { $subjectAdmin = "🔔 New Webinar Registration: " . $user['name']; $phoneStr = !empty($user['country_code']) ? "+" . $user['country_code'] . " " . $user['phone'] : $user['phone']; $addonStr = $user['reminder_added'] ? "Yes (+₹40)" : "No"; $htmlAdmin = " <div style='background-color: #0a0e17; color: #ffffff; padding: 40px; font-family: sans-serif; max-width: 600px; margin: 0 auto; border-radius: 8px; border: 1px solid #1a2233;'> <h2 style='color: #00e676; border-bottom: 1px solid #1a2233; padding-bottom: 15px; margin-bottom: 20px;'>🔔 New Registrant Alert</h2> <table style='width: 100%; border-collapse: collapse; font-size: 14px;'> <tr style='border-bottom: 1px dashed rgba(255,255,255,0.05);'><td style='padding: 10px; color: #8892b0;'><strong>Full Name:</strong></td><td style='padding: 10px; color: #fff;'>" . htmlspecialchars($user['name']) . "</td></tr> <tr style='border-bottom: 1px dashed rgba(255,255,255,0.05);'><td style='padding: 10px; color: #8892b0;'><strong>Email Address:</strong></td><td style='padding: 10px; color: #fff;'>" . htmlspecialchars($user['email']) . "</td></tr> <tr style='border-bottom: 1px dashed rgba(255,255,255,0.05);'><td style='padding: 10px; color: #8892b0;'><strong>Phone Contact:</strong></td><td style='padding: 10px; color: #fff;'>$phoneStr</td></tr> <tr style='border-bottom: 1px dashed rgba(255,255,255,0.05);'><td style='padding: 10px; color: #8892b0;'><strong>Call Reminder:</strong></td><td style='padding: 10px; color: #fff;'>$addonStr</td></tr> <tr style='border-bottom: 1px dashed rgba(255,255,255,0.05);'><td style='padding: 10px; color: #8892b0;'><strong>Amount Paid:</strong></td><td style='padding: 10px; color: #00e676; font-weight: bold;'>₹" . number_format($user['amount_paid'], 2) . "</td></tr> <tr style='border-bottom: 1px dashed rgba(255,255,255,0.05);'><td style='padding: 10px; color: #8892b0;'><strong>Razorpay Order ID:</strong></td><td style='padding: 10px; color: #fff; font-family: monospace;'>" . htmlspecialchars($user['razorpay_order_id']) . "</td></tr> <tr style='border-bottom: 1px dashed rgba(255,255,255,0.05);'><td style='padding: 10px; color: #8892b0;'><strong>Transaction ID:</strong></td><td style='padding: 10px; color: #fff; font-family: monospace;'>" . htmlspecialchars($user['payment_id']) . "</td></tr> </table> <div style='margin-top: 25px;'> <strong style='color: #8892b0; font-size: 14px;'>Student Goals:</strong> <p style='background: rgba(0,0,0,0.2); padding: 15px; border-radius: 6px; font-size: 13px; color: #8892b0; line-height: 1.5; margin-top: 8px; border: 1px solid #1a2233;'>" . nl2br(htmlspecialchars($user['message'])) . "</p> </div> </div>"; SimpleMailer::send($toAdmin, $subjectAdmin, $htmlAdmin); } }
SAVE
CANCEL