What are the best practices for setting up a mail server for PHP development on localhost?

Setting up a mail server for PHP development on localhost involves configuring a local SMTP server like Postfix or Sendmail to handle outgoing emails from your PHP scripts. This allows you to test email functionality without sending actual emails to real recipients.

// Example configuration for sending emails using PHP's mail function with a local SMTP server
ini_set('SMTP', 'localhost');
ini_set('smtp_port', 25);

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

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