So I've been scouring the web on this issue, and almost every example was condemned as a firewall or server related problem. From what I can tell, my server is connecting just fine to gmail, but PHPMailer still fails to connect. Here is my PHP:
require_once($_SERVER['DOCUMENT_ROOT']."/phpmailer/class.phpmailer.php");
$host = "smtp.gmail.com";
$port = "587";
$checkconn = fsockopen($host, $port, $errno, $errstr, 5);
if(!$checkconn){
echo "($errno) $errstr";
} else {
echo 'Connected through fsocketopen.<br />';
}
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->Host = "smtp.gmail.com";
$mail->SMTPAuth = true;
$mail->SMTPSecure = "ssl";
$mail->Username = "myemail@gmail.com";
$mail->Password = "********";
$mail->Port = "587";
The credentials are not shown, but are 100% correct. Here are the results:
Connected through fsocketopen.
Mailer Error: SMTP Connect() failed.
As you can see, the server is allowing a connection to gmail through fsocketopen, but PHPMailer will not connect. I've even accessed my server through SSH, and received the following response:
-bash-4.1$ telnet smtp.gmail.com 587 Trying 2607:f8b0:400d:c02::6d... Connected to smtp.gmail.com. Escape character is '^]'. 220 mx.google.com ESMTP g1sm52568728qec.9 - gsmtp
So two tests verify connection between my server and Gmail is available. So now I'm left to assume that there is a problem with my PHPMailer. I've scanned through the class.phpmailer.php file, but I just don't know enough about it to see where there would be a problem. Any help is appreciated!