PHPMailer Hangs on Send

user2221400 picture user2221400 · Mar 28, 2013 · Viewed 8.1k times · Source

I had successfully setup a web app using WAMPSERVER on a desktop used by a few people internally, this used PHPMailer to an internal SMTP server without encryption or authentication and it worked.

That desktop crashed and I've migrated to a "new" desktop. I had an SVN setup so I was even using most of the same files and config. One difference which might matter is that the old desktop was 64-bit and the new is 32-bit. This means I'm using different versions of WAMPSERVER.

The mailer just hangs. I don't get a PHP error or a PHP timeout. I just never reach the end of my script. The crazy part about this is that it works with authentication, ssl, and gmail. It just won't work with the extra simple case I need.

This works:

<?php
require('class.phpmailer.php');
$mail=new PHPMailer();
$mail->ISSMTP();
$mail->Host='smtp.gmail.com';
$mail->Subject='test subj';
$mail->Body='the body email test';
$mail->SMTPDebug  = 1;                     // enables SMTP debug information (for testing)
$mail->SMTPAuth   = true;                  // enable SMTP authentication
$mail->SMTPSecure = "ssl";                 // sets the prefix to the servier
$mail->Host       = "smtp.gmail.com";      // sets GMAIL as the SMTP server
$mail->Port       = 465;                   // set the SMTP port for the GMAIL server
$mail->Username   = "[email protected]";  // GMAIL username
$mail->Password   = "mypassword";            // GMAIL password
$mail->AddAddress('[email protected]', 'John Doe');
$mail->SetFrom('[email protected]', 'First Last');
$mail->Send();
?>

this used to, but now does not:

<?php
require('class.phpmailer.php');
$mail=new PHPMailer();
$mail->ISSMTP();
$mail->Host='smtp.internal.com';
$mail->Subject='test subj';
$mail->Body='the body email test';
$mail->SMTPDebug  = 1;                     // enables SMTP debug information (for testing)
$mail->Port       = 25;                   // set the SMTP port for the GMAIL server
$mail->AddAddress('[email protected]', 'John Doe');
$mail->SetFrom('[email protected]', 'First Last');
$mail->Send();
?>

The only thing I get from debug is

CLIENT -> SMTP: EHLO thedesktophostname

No errors display on the page and nothing in the apache log, where I normally get PHP errors, if they don't display.

I can telnet to the host from the desktop on port 25 and even type in the EHLO command and get a good response from the server.

I don't remember having this issue before, although it's possibly I've already solved it once. I couldn't find anything that helped here or on The Google.

Please help. Thanks.

Answer

Louise McMahon picture Louise McMahon · Jun 15, 2015

Hijacking the post to say i had the same issue but had set the port to 465 without setting SMTPSecure to 'ssl' in the example its set TLS by default