Why does PHP still attempt to connect to "localhost" for mail server access even after specifying a different IP address in the PHP.ini file?

PHP may still attempt to connect to "localhost" for mail server access because the configuration in the PHP.ini file may not have been properly updated or saved. To solve this issue, ensure that the correct IP address of the mail server is specified in the PHP.ini file and that the changes are saved correctly.

// Update the SMTP settings in PHP.ini file
ini_set('SMTP', 'mail.example.com');
ini_set('smtp_port', '25');