<?php
$fullname=$_POST['fullname'];
$email=$_POST['email'];
$subject=$_POST['subject'];
$message=$_POST['message'];

use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\SMTP;
use PHPMailer\PHPMailer\Exception;

require_once __DIR__ . '/vendor/phpmailer/src/Exception.php';
require_once __DIR__ . '/vendor/phpmailer/src/PHPMailer.php';
require_once __DIR__ . '/vendor/phpmailer/src/SMTP.php';

// passing true in constructor enables exceptions in PHPMailer
$mail = new PHPMailer(true);

try {
    // Server settings
    //$mail->SMTPDebug = SMTP::DEBUG_SERVER; // for detailed debug output
    $mail->isSMTP();
	$mail->CharSet = 'UTF-8';
    $mail->Host = 'ssl0.ovh.net';
    $mail->SMTPAuth = true;
    $mail->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS;
    $mail->Port = 587;

    $mail->Username = 'karimmharsi@wvue.net'; // YOUR gmail email
    $mail->Password = 'karim123456'; // YOUR gmail password

    // Sender and recipient settings
    $mail->setFrom('karimmharsi@wvue.net', $fullname);
    $mail->addAddress('mharsikarim@gmail.com', 'Karim');
    $mail->addReplyTo('karimmharsi@wvue.net', 'Name'); // to set the reply to

    // Setting the email content
    $mail->IsHTML(false);
    $mail->Subject = $subject;
    $mail->Body = 'Email from: '.$email.'   :   '.$message;
    $mail->AltBody = '';

    $mail->send();
    echo "done";
} catch (Exception $e) {
    echo "error";
}
?>
