Your IP : 216.73.216.86


Current Path : /home/emeraadmin/public_html/4d695/
Upload File :
Current File : /home/emeraadmin/public_html/4d695/emailUtils.php.tar

home/emeraadmin/public_html/pages/emailUtils.php000064400000002456151677420240016037 0ustar00<?php

require __DIR__ . '/../vendor/autoload.php';
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;

// Function to send email
function sendEmail($to, $subject, $body, $isHTML = true, $template = null, $placeholders = [])
{
    $mail = new PHPMailer(true);

    try {
        // Server settings
        $mail->isSMTP();
        $mail->Host = 'localhost';
        $mail->SMTPAuth = false;
        $mail->SMTPAutoTLS = false;
        $mail->Port = 25;

        // Recipients
        $mail->setFrom('mail@emerateamkids.com', 'emerateamkids.com'); // Replace with your GoDaddy email and name
        $mail->addAddress($to);

        // Load and process HTML email template if provided
        if ($template) {
            $emailTemplate = file_get_contents($template);
            foreach ($placeholders as $key => $value) {
                $emailTemplate = str_replace("[$key]", $value, $emailTemplate);
            }
            $body = $emailTemplate;
        }

        // Content
        $mail->isHTML($isHTML);
        $mail->Subject = $subject;
        $mail->Body    = $body;

        $mail->send();
        return "Email sent to $to";
    } catch (Exception $e) {
        return "Message could not be sent. Mailer Error: {$mail->ErrorInfo}";
    }
}

?>