Blog

Home  /  Coding   /  How To Use PHP Mailer | AV Coding

How To Use PHP Mailer | AV Coding

Hey guys welcome to AV Coding

Today we will learn how to use PHP Mailer.

PHP Mailer Files : https://github.com/PHPMailer/PHPMailer/tree/master/src

G-MAIL 2 Step Method: https://github.com/PHPMailer/PHPMailer/wiki/Using-Gmail-with-XOAUTH2

G-MAIL Less Secure Settings : https://myaccount.google.com/lesssecureapps

Email Design Limitations: https://mailchimp.com/help/limitations-of-html-email/

PHP Mailer Documentation: https://phpmailer.github.io/PHPMailer/classes/PHPMailer.PHPMailer.PHPMailer.html

The complete code is explained in the video below and the source code is provided below.

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

$mail = new PHPMailer\PHPMailer\PHPMailer();
$mail->IsSMTP();
$mail->SMTPDebug  = 1;
$mail->Debugoutput = 'html';
$mail->Host = 'smtp.gmail.com';
$mail->Port = 587;
$mail->SMTPSecure = 'tls';
$mail->SMTPAuth   = true;
$mail->Username   = "avcoding@gmail.com";
$mail->Password   = "*********";
$mail->SetFrom('avcoding@gmail.com', "AV CODING");
$mail->AddReplyTo('avcoding@gmail.com', "AV CODING");
// Use $email And $name as the emailid to whom you want to send the mails
$mail->AddAddress($email, $name);
$mail->Subject = "AV CODING Forgot Password";
$mail->Body = '';
$mail->IsHTML(true);
if(!$mail->Send()) {
    echo "Message not sent";
  } else {
    echo "Message sent!";
  }

?>

Hope You Liked This Blog. Share, Comment, Subscribe And Press The Bell Icon In The Bottom Right Side For More Code Feeds.