How can one test if a PHP script is sending emails via SMTP or the mail function?

To test if a PHP script is sending emails via SMTP or the mail function, you can check the configuration settings in the PHP script. If the script is using SMTP, it will typically include settings such as host, port, username, and password for the SMTP server. If the script is using the mail function, it will not have these SMTP settings.

// Check if SMTP settings are present
if(isset($smtp_host) && isset($smtp_port) && isset($smtp_username) && isset($smtp_password)){
    echo "Emails are being sent via SMTP.";
} else {
    echo "Emails are being sent using the mail function.";
}