JezK
Edit File: ajax_user_status.php
<?php include_once('includes/connect_database.php'); use PHPMailer\PHPMailer\PHPMailer; use PHPMailer\PHPMailer\Exception; use PHPMailer\PHPMailer\OAuth; use League\OAuth2\Client\Provider\Google; include_once('composer_test/vendor/autoload.php'); // echo $_POST['userid'];exit; $userid = $_POST['userid']; // echo $userid;exit; $sql = 'select * from mstusers where Userid='.$userid.''; // echo $sql;exit; $test = mysqli_query($connect,$sql); $newUser = mysqli_fetch_assoc($test); if($newUser['isApproved']==0 || $newUser['isActive'] ==0){ $tpp="Dear User,<br/> <br/>Your account has been verified.<br/><br/> You can now log into the Pharisee App using your registered Email Address and Password set by you.<br/><br/> Thank You."; mysqli_query($connect,"update mstusers set isApproved=1,isActive=1 where Userid=".$_POST['userid']); $type=7; $notifyMesg="Your account has been verified"; $mess="Your account has been verified"; $user=$_POST['userid']; // echo $user;exit; include("public/android_single.php"); }else{ $tpp="Dear User,<br/> Your Pharisee account has been deactivated by Admin. Please Contact Admin for further details"; mysqli_query($connect,"update mstusers set isApproved=0,isActive=0 where Userid=".$_POST['userid']); $type=8; $notifyMesg="Sorry, Your account is deactivated"; $mess="Sorry, Your account is deactivated"; $user=$_POST['userid']; include("public/android_single.php"); } $to=$newUser['Email']; $subject="Pharisee admin notification"; $txt = "<html><head></head><body>"; $txt .= '<div align="center"> <div style="width:848px;" align="center"> <div align="center" style="background:#c4cad0ad" >'; $txt .= '<img src=" http://bu1is.krify.com/pharisee/images/logo.png" width="200" style="margin:30px 0px 0px 30px;"/> </div><div style="background:#F1F3F3;height:auto; padding:30px;" align="left">'; $txt .= $tpp; // $body .= "Content-Type: text/html; charset=ISO-8859-1\r\n"; // $body .= "Content-Transfer-Encoding: base64\r\n\r\n"; //mail($to,$subject,$txt,$body); smtpMail($to,$subject,$txt); function smtpMail($to,$subject,$message) { $google_email = 'soniya@krify.net'; $oauth2_clientId = '700907010903-1vf4imsl2473a9rr5vuu1f1e517envmc.apps.googleusercontent.com'; $oauth2_clientSecret = 'i5hLj29ch4v3ZjxrvoHCS-bc'; $oauth2_refreshToken = '1//04M3-VC8qoo-4CgYIARAAGAQSNwF-L9Ir9SKk1vBMWirm9fqisPAsgQnK4XuA4dDkP4no0iubLo8eVKve5KwxouQl_AFWS-q320k'; $mail = new PHPMailer(TRUE); try { $mail->setFrom($google_email, '1MH Fitness'); if(is_array($to)){ if($to!=""){ foreach($to as $to1){ $mail->addAddress($to1); } } } else{ $mail->addAddress($to); } $mail->Subject = $subject; $mail->Body =$message; $mail->isSMTP(); $mail->Port = 587; $mail->SMTPOptions = array( 'ssl' => array( 'verify_peer' => false, 'verify_peer_name' => false, 'allow_self_signed' => true ) ); $mail->SMTPAuth = TRUE; $mail->SMTPSecure = 'tls'; $mail->IsHTML(true); /* Google's SMTP */ $mail->Host = 'smtp.gmail.com'; /* Set AuthType to XOAUTH2. */ $mail->AuthType = 'XOAUTH2'; /* Create a new OAuth2 provider instance. */ $provider = new Google( [ 'clientId' => $oauth2_clientId, 'clientSecret' => $oauth2_clientSecret, ] ); /* Pass the OAuth provider instance to PHPMailer. */ $mail->setOAuth( new OAuth( [ 'provider' => $provider, 'clientId' => $oauth2_clientId, 'clientSecret' => $oauth2_clientSecret, 'refreshToken' => $oauth2_refreshToken, 'userName' => $google_email, ] ) ); /* Finally send the mail. */ if ($mail->send()) { echo "Mail sent successfully"; exit; return 1; } else { echo "Mail not sent"; } } catch (Exception $e) { echo $e->errorMessage(); } catch (\Exception $e) { echo $e->getMessage(); } } include_once('includes/close_database.php'); ?>