How to change sender mail id in php sql

To change the sender email ID in PHP when sending an email using SQL, you can use the mail() function and specify the From header. Here's an example:

<?php
// Define the email address you want to send from
$from_email = '[email protected]';

// Define the email address you want to send to
$to_email = '[email protected]';

// Define the subject and message
$subject = 'Test email';
$message = 'This is a test email';

// Set the headers
$headers = 'From: '. $from_email. "\r\n".
           'Reply-To: '. $from_email. "\r\n".
           'MIME-Version: 1.0'. "\r\n".
           'Content-Type: text/plain; charset=UTF-8';

// Send the email
mail($to_email, $subject, $message, $headers);

?>

In this example, the From header is set to [email protected], which will be used as the sender email ID.

If you're using a PHPMailer class, you can set the From address using the setFrom() method:

<?php
require_once 'PHPMailer/PHPMailer.php';
require_once 'PHPMailer/SMTP.php';

$mail = new PHPMailer\PHPMailer\PHPMailer();
$mail->isSMTP();
$mail->Host = 'smtp.example.com';
$mail->Port = 587;
$mail->SMTPAuth = true;
$mail->Username = '[email protected]';
$mail->Password = 'your_password';

$mail->setFrom('[email protected]', 'Your Name');
$mail->addAddress('[email protected]');
$mail->Subject = 'Test email';
$mail->Body = 'This is a test email';

$mail->send();
?>

In this example, the setFrom() method is used to set the From address to [email protected].

Note that you should replace [email protected] with the actual email address you want to use as the sender. Also, make sure to configure your email server settings correctly to ensure that the email is sent successfully.