How to use smtp phpmailer with free webhosting

hi there please help me out i am not receiving any email with this php mailer script
please help me out to run this

<?php
// Import PHPMailer classes into the global namespace
// These must be at the top of your script, not inside a function
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
//Load Composer's autoloader
require 'vendor/autoload.php';
function send_email($recipient_email,$recipient_name,$subject,$message)
{

    $mail = new PHPMailer(false);                              // Passing `true` enables exceptions
    //Server settings
    //$mail->SMTPDebug = 2;                                 // Enable verbose debug output
    $mail->isSMTP();                                      // Set mailer to use SMTP
    $mail->Host = 'mail.example.com';  // Specify main and backup SMTP servers
    $mail->SMTPAuth = true;                               // Enable SMTP authentication
    $mail->Username = 'info@example.com';                 // SMTP username
    $mail->Password = 'xxxxx';                           // SMTP password
    $mail->SMTPSecure = 'tls';                            // Enable TLS encryption, `ssl` also accepted
    $mail->Port = 587;                                    // TCP port to connect to

    //Recipients
    $mail->setFrom(APP_FROM_EMAIL, APP_NAME);
    $mail->addAddress($recipient_email, $recipient_name);     // Add a recipient

    //Content
    $mail->isHTML(true);                                  // Set email format to HTML
    $mail->Subject = $subject;
    $mail->Body    = $message;
    //$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';

    $mail->send();
    //echo 'Message has been sent';
}

Are you using gmail?

yes i am using gmail

please help me out this script and using smtp importation for validation on my app but i am not receiving any email

help me out ckhawand i am not able to receive email

Then please follow this tutorial

This topic was automatically closed after 21 hours. New replies are no longer allowed.