What are best practices for configuring PHP to send emails via SMTP on a root server?

Configuring PHP to send emails via SMTP on a root server involves setting up the SMTP server details in the php.ini file. This includes specifying the SMTP server address, port, authentication method, username, and password. By correctly configuring these settings, PHP can send emails using the specified SMTP server.

// Set the SMTP server details in php.ini file
ini_set('SMTP', 'smtp.example.com');
ini_set('smtp_port', 587);
ini_set('sendmail_from', 'your_email@example.com');
ini_set('auth_username', 'your_username');
ini_set('auth_password', 'your_password');