If you intend you use SMTP, add your SMTP Code after this Line



PHP Snippet 1:

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

$mail = new PHPMailer\PHPMailer\PHPMailer();


try {
    $mail->IsSMTP(); // enable SMTP
    $mail->CharSet = 'UTF-8';
    $mail->SMTPDebug = 2; // debugging: 1 = errors and messages, 2 = messages only
    $mail->SMTPAuth = true; // authentication enabled
    $mail->SMTPSecure = 'ssl'; // secure transfer enabled REQUIRED for Gmail
    $mail->Host = "smtp.gmail.com";
    $mail->Port = 465; // or 587
    $mail->IsHTML(true);
    $mail->Username = "Your Email Address";
    $mail->Password = "Your Password";
    $mail->SetFrom("From Name");
    $mail->Subject = "Message Subject";
    $mail->Body ="Message Body ";
    $mail->AddAddress('Sent email to this address');

    if($mail->Send()) {
        // e-posta ba?ar?l? ile gönderildi
      echo 'success';
    } else {
        echo 'error';
    }
} catch (Exception $e) {
    echo 'error : '.$e;
}