📄 phpmailerInclude.php

Size: 2,733 bytes
Path: /home/islandholiday/public_html/phpmailerInclude.php
Modified: 2026-01-09 13:25:36
<?php
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\SMTP;
use PHPMailer\PHPMailer\Exception;

require 'PHPMailer/PHPMailer/src/Exception.php';
require 'PHPMailer/PHPMailer/src/PHPMailer.php';
require 'PHPMailer/PHPMailer/src/SMTP.php';


//Load Composer's autoloader
//require 'vendor/autoload.php';

//Create an instance; passing `true` enables exceptions
$mail = new PHPMailer(true);


try { 
    //Server settings
    //$mail->SMTPDebug = SMTP::DEBUG_SERVER;                      //Enable verbose debug output
    $mail->isSMTP();                                            //Send using SMTP
    $mail->Host       = "mail.z-villagelodge.co.tz";                                        //
    //$mail->SMTPDebug = 0;                                                    //'smtp.example.com';                     
                                                                    //Set the SMTP server to send through
    $mail->SMTPAuth   = true;                                   //Enable SMTP authentication
    // $mail->Username   = 'no-reply@safari-zanz.co.tz';                     //SMTP username
    // $mail->Password   = 'YE$j=NFcyi?7';
      $mail->Username   = 'no-reply@z-villagelodge.co.tz';                     //SMTP username
    $mail->Password   = 'Zvillage@2026#bdoiwr65#V';                               //SMTP password
    $mail->SMTPSecure = PHPMailer::ENCRYPTION_SMTPS;            //Enable implicit TLS encryption
    $mail->Port       = 465;                                    //TCP port to connect to; use 587 if you have set `SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS`

    //Recipients
    $mail->setFrom("no-reply@z-villagelodge.co.tz", "Z Village Lodge ");
    //$mail->addAddress("info@tumtours.co.tz", "Juma Tours & Safaris");     //Add a recipient
    $mail->addAddress($Clientemail,$fullname); //email to              //Name is optional
    //$mail->addReplyTo('info@example.com', 'Information');
    //$mail->addCC('cc@example.com');
    $mail->addCC('info@z-villagelodge.co.tz');
    //$mail->addCC('farsombinsalim@gmail.com');

    //Attachments
    //$mail->addAttachment('/var/tmp/file.tar.gz');         //Add attachments
    //$mail->addAttachment('/tmp/image.jpg', 'new.jpg');    //Optional name

    //Content
    $mail->isHTML(true);                                  //Set email format to HTML
    // $mail->Subject = 'Here is the subject';
    // $mail->Body    = 'This is the HTML message body <b>in bold!</b>';
    // $mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
    $mail->Subject = $subject;
    $mail->Body    = $htmlEmail;
    $mail->AltBody = $htmlEmail;

    $mail->send();
    exit();
    //echo 'Message has been sent';
} catch (Exception $e) {
    //echo "Message could not be sent. Mailer Error: {$mail->ErrorInfo}";
}