<?php
// One-page email sender using PHPMailer

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

//require 'vendor/autoload.php'; // Requires: composer require phpmailer/phpmailer
if (empty($_POST)) {
    echo "No POST data was submitted.";
} else {
 /*    echo "POST data received."; */
    // You can then iterate through $_POST or access specific elements

$mail = new PHPMailer(true);

try {
    // SMTP config
    $mail->isSMTP();
    $mail->Host       = 'smtp.bizmail.yahoo.com';      // SMTP server
    $mail->SMTPAuth   = true;
    $mail->Username   = 'it@titlispharma.com'; // Your email
    $mail->Password   = 'wbigiyipbamrxyhb';    // App password (not your real password)
    $mail->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS;
    $mail->Port       = 587;

    // Email content
    $mail->setFrom('it@titlispharma.com', $_REQUEST['yourname']);
    $mail->addAddress('it@titlispharma.com');
    $mail->Subject = 'Mr. '. $_REQUEST['yourname'] . ' sent a message using Synapse website.';
    $mail->Body    = $_REQUEST['message'].'<br> <br><br> Regards <br>'.$_REQUEST['yourname']. '<br>' . $_REQUEST['email']. '<br>' . $_REQUEST['number'];
    $mail->AltBody = 'Plain text version of the email';

    // Send
    $mail->send();
    echo 'Email sent successfully!';
} catch (Exception $e) {
    echo 'Mailer Error: ' . $mail->ErrorInfo;
}
}
?>