How can I send an email using the correct mail server in PHP?

When sending an email in PHP, it is important to specify the correct mail server to ensure that the email is delivered successfully. You can achieve this by using the `ini_set()` function to set the `SMTP` and `smtp_port` configuration values in your PHP script. By setting these values to the appropriate mail server address and port, you can ensure that the email is sent via the correct mail server.

// Set the SMTP server and port
ini_set('SMTP', 'mail.example.com');
ini_set('smtp_port', 25);

// Send email
$to = 'recipient@example.com';
$subject = 'Test Email';
$message = 'This is a test email.';
$headers = 'From: sender@example.com';

mail($to, $subject, $message, $headers);