Are there any specific security settings or firewall rules that could be blocking the connection to smtp.gmail.com on a local machine?

If the connection to smtp.gmail.com is being blocked on a local machine, it could be due to security settings or firewall rules preventing outgoing connections on port 587 (SMTP). To resolve this, you may need to adjust the firewall settings to allow outgoing connections to smtp.gmail.com on port 587.

// Example PHP code to adjust firewall settings to allow outgoing connections to smtp.gmail.com on port 587
// Note: This code is just an example and may need to be adjusted based on your specific firewall configuration

// Allow outgoing connections on port 587 for smtp.gmail.com
exec('sudo ufw allow out 587/tcp to smtp.gmail.com');

// Reload firewall rules
exec('sudo ufw reload');