<?php
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\SMTP;
use PHPMailer\PHPMailer\Exception;
require 'vendor/autoload.php';
$subject = 'News Trends Email Testing';
$message = '<html><body><center>News Trends 24x7</center>';
$message.= 'Email Testing From News Trends 24x7';
$message.= '</table></body></html>';
$mail = new PHPMailer(true);
try {
$mail->isSMTP();
$mail->Host = 'smtp.gmail.com';
$mail->SMTPAuth = true;
$mail->Username = 'newstrends24x7@gmail.com';
$mail->Password = 'Email Password';
$mail->SMTPSecure = PHPMailer::ENCRYPTION_SMTPS;
$mail->Port = 465;
$mail->setFrom('newstrends24x7@gmail.com', 'News Trends 24x7');
$mail->addAddress('Receiver Email', 'Receiver Name');
$mail->addReplyTo('newstrends24x7@gmail.com', 'News Trends 24x7');
$mail->isHTML(true);
$mail->Subject = $subject;
$mail->Body = $message;
$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
$mail->send();
}
catch (Exception $e) {
echo "Message could not be sent. Mailer Error: {$mail->ErrorInfo}";
}
Download PHPMailer from Below and Extract and Place it in root directory of Project
