I noticed that require(), require_once(), include() and include_once()
methods were somehow not working. The files that were called using these methods were not being called and the code stopped executing forward from this point.
After a lot of Googling and R&D I didn’t find any solution to making the above methods work.
So I decided to look into the architecture of the tweentysixteen
theme and found out that there was a built in function of WordPress that it used to include other PHP files.
So I thought of trying that out to include the class.PHPMailer.php and PHPMailerAutoload.php
files. If changed the lines
require("PHPMailer/class.PHPMailer.php");
require 'PHPMailer/PHPMailerAutoload.php';
in my code to,
get_template_part('PHPMailer/class.PHPMailer');
get_template_part('PPHPMailer/PHPMailerAutoload');
and finally I was able to fix the issue and the contact form started working.