File "mail.php"

Full path: /home/fsibplc/public_html/firstcash/mail.php
File size: 2.27 B (2.27 KB bytes)
MIME-type: text/x-php
Charset: utf-8

Download   Open   Edit   Advanced Editor   Back

<?php 
use PHPMailer\PHPMailer\PHPMailer;

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

$mail = new PHPMailer(true);

$alert ='';

if(isset($_POST['submit'])){
    $name = $_POST['name'];
    $email = $_POST['email'];
    $phone = $_POST['phone'];
    $subject = $_POST['subject'];
    $message = $_POST['message'];
   
    try {
        // Server settings
        $mail->SMTPDebug = 2;                      // Enable verbose debug output
        $mail->isSMTP();                                            // Send using SMTP
        $mail->Host       = 'mail.fsiblbd.com';                    // Set the SMTP server to send through
        $mail->SMTPAuth   = true;                                   // Enable SMTP authentication
        $mail->Username   = 'firstcash@fsiblbd.com';                     // SMTP username
        $mail->Password   = 'Ryhan@04666';                               // SMTP password
       $mail->SMTPSecure = 'tls';         // Enable TLS encryption; `PHPMailer::ENCRYPTION_SMTPS` encouraged
        $mail->Port       = 465;            

        // Recipients
        $mail->setFrom('firstcash@fsiblbd.com', 'MFS');
        $mail->addAddress('ryhankazi@gmail.com', 'Ryhan');     // Add a recipient
    // $mail->addAddress('ellen@example.com');               // Name is optional
    // $mail->addReplyTo('info@example.com', 'Information');
    // $mail->addCC('cc@example.com');
    // $mail->addBCC('bcc@example.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 = 'Message Recieved From Contact:' . $name;
        $mail->Body    = "Name: $name <br>Phone: $phone <br>Email: $email <br>Subject: $subject <br>Message: $message";
        // $mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
        $mail->send();
        $alert = "<div>Message Sent !</div>";
    } catch(Exception $e){
        $error = $e->getMessage();
        $alert = "<div>'.$error.'</div>";
    }
}
?>