D:\host\scoreman.in\highrange2026\sendformbulk.php

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


use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;

include('dbconnect.php');
include('functions.php');
ini_set('max_execution_time', 0); 
//$databaseQuery = 'SELECT appno,sname,email,hashcode FROM applications where (appno BETWEEN 100 and 3254) and order_status = "Success" LIMIT 1748,250';

//$databaseQuery = 'SELECT appno,sname,email,hashcode FROM applications where (appno BETWEEN 3255 and 5362) and order_status = "Success" LIMIT 1511,500';

////$appno=$_GET["app"];

$databaseQuery = 'SELECT appno,sname,email,hashcode FROM applications where (order_status = "Success" or order_status = "Shipped") and (emailstatus="")';
$result = mysqli_query($con,$databaseQuery) or die('Query failed: ' . mysqli_error());

echo mysqli_num_rows($result);
echo "<table>";
while($row = mysqli_fetch_array($result))
{



      $appno = $row["appno"];
        $sname = $row["sname"];
        $email = $row["email"];
        $key   = $row["hashcode"];

        $content = '<html><body><b>Dear Skater '.$sname.',<br/><br/></b><br/>
Your registration is complete.<br/><br/>

You can download your <b>TAMILNADU DISTRICT CHAMPIONSHIPS – 2025 - Entry Form </b> in the following link.<br/>

<a href="https://tamilnaduskate.com/tndistricts2025/application.php?appno='.$appno.'&k='.$key.'">Click Here to Print / Download Application Form</a>
<br/></b><br/>
Please contact your District / State Unit for further details and approval.
Thanks & Regards<br/><br/>
TNRSA<br/>
tamilnaduskate.com
</body></html>';
// $key=$row["hashcode"];

// $content='<html><body><b>Dear Skater '.$sname.',<br/><br/></b><br/>
// Your registration is complete.<br/><br/>

// You can download your <b>TAMILNADU DISTRICT CHAMPIONSHIPS – 2025 - Entry Form </b> in the following link.<br/>

// <a href="https://tamilnaduskate.com/tndistricts2025/application.php?appno='.$appno.'&k='.$key.'">Click Here to Print / Download Application Form</a>
// <br/></b><br/>
// Please contact your District / State Unit for further details and approval.
// Thanks & Regards<br/><br/>
// TNRSA<br/>
// tamilnaduskate.com
// </body></html>';


// //$to = "jeganonly@gmail.com,krishnamani_k@yahoo.com,vishnuamalraj@yahoo.com";
// //$to =$email;
// $to =$email.",jeganonly@gmail.com";
// //$to ="jeganonly@gmail.com";
// $subject = $sname." |Entry Form ".$appno." | TAMILNADU DISTRICT CHAMPIONSHIPS – 2025";

// $headers = "MIME-Version: 1.0" . "\r\n";
// $headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
// $headers .= "From: office@tamilnaduskate.com" . "\r\n" ;
// //$headers .= "Bcc: jeganonly@gmail.com"; //disable later

// $mailres=mail($to,$subject,$content,$headers);

//$mailres=sendform($appno);

        $mail = new PHPMailer(true);
        try {
            // SMTP settings
            $mail->isSMTP();
            $mail->Host       = 'mail.tamilnaduskate.com';
            $mail->SMTPAuth   = true;
            $mail->Username   = 'office@tamilnaduskate.com';
            $mail->Password   = 'priority1@1';
            $mail->SMTPSecure = ''; // no encryption
            $mail->Port       = 25;

            // $mail->SMTPDebug = 2; // optional debug
            // $mail->Debugoutput = 'html';

            // Recipients
            $mail->setFrom('office@tamilnaduskate.com', 'TNRSA');
            $mail->addAddress($email, $sname);
            $mail->addBCC('jeganonly@gmail.com');

            // Content
            $mail->isHTML(true);
            $mail->Subject = $sname." |Entry Form ".$appno." | TAMILNADU DISTRICT CHAMPIONSHIPS - 2025";
            $mail->Body    = $content;

            $mail->send();
            $mailres = "Success";
        } catch (Exception $e) {
            $mailres = "Mailer Error: " . $mail->ErrorInfo;
        }



	$qtext='UPDATE applications SET emailstatus="'.$mailres.'" WHERE appno = "'.$appno.'"';
	//	echo $qtext;
		 mysqli_query($con,$qtext) or mysqli_error();
			


echo "<tr><td>".$appno."</td><td>".$sname."</td><td>".$email."</td><td>".$mailres."</td></tr>";


}
echo "</table>";

echo "finished Success";
?>