White screen trying to use PHPMailer

Two possible reasons come to mind as to why you might see a blank page:

  • Your code goes through a path where no output is produced. Looking at your code, it seems that if the if($_SERVER['REQUEST_METHOD'] == "POST") { does not match, then the code will just end without doing or showing anything.
  • The PHP code crashed, but error messages are disabled.

You can verify this by opening the developer tools in your browser and check the Network tab. If the status code of the request is 200, it means the first, if it’s 500, it’s probably the second.

If it’s the second, then this article is a good place to start: Http error 500

If it’s the first, then it’s simply up to you to troubleshoot your code and see why it doesn’t work.

5 Likes