What are some common mistakes that could lead to a website getting stuck after sending an email in PHP?

One common mistake that could lead to a website getting stuck after sending an email in PHP is not properly closing the connection to the mail server. This can cause the script to hang indefinitely while waiting for a response from the server. To solve this issue, make sure to close the connection to the mail server after sending the email.

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

// Close the connection to the mail server
if ($mail_sent) {
    // Close the connection to the mail server
    ini_set('SMTP', '');
    ini_set('smtp_port', '');
}