How can the PHP error log be accessed to troubleshoot email sending issues with PHPMailer?

To troubleshoot email sending issues with PHPMailer, you can access the PHP error log to see any error messages or warnings that may be occurring during the email sending process. This can help identify the root cause of the problem and provide insights into how to resolve it.

// Enable error logging for PHPMailer
$mail = new PHPMailer(true);
$mail->SMTPDebug = 2; // Enable verbose debug output

// Send email
try {
    $mail->send();
    echo 'Email sent successfully';
} catch (Exception $e) {
    echo 'Email could not be sent. Error: ' . $mail->ErrorInfo;
}