How can PHP scripts ensure that the headers, such as From and Reply-To, are not altered by the server when sending emails?

When sending emails using PHP, the server may alter the headers, such as the From and Reply-To fields, which can lead to delivery issues or incorrect sender information. To ensure that these headers are not altered, you can use the `ini_set` function in PHP to set the `sendmail_from` directive to the desired email address before sending the email.

// Set the sender email address to prevent server from altering the From header
ini_set('sendmail_from', 'your_email@example.com');

// Define email headers
$headers = 'From: your_email@example.com' . "\r\n" .
           'Reply-To: your_email@example.com' . "\r\n";

// Send email
mail('recipient@example.com', 'Subject', 'Message', $headers);