Send emails using gmail adress: SMTP Error: Could not connect to SMTP host

Im sending emails with phpmail class, and for now Im just testing in localhost and it is working fine until today.

I was testing using a gmail adress and my send email configuration is like this:


And, with this configuration above I was sending mails witth sucess until today. But now its not working, Im always getting this error: SMTP Error: Could not connect to SMTP host.

So I try to use a hotmail email to see if it works, and I really dont understand why but with hotmail Im sending emails with sucess, like this:

Do you see why this can be happening?

My function:

function sendMail($subject,$message,$from,$nameFrom,$to,$nameTo, $attachment = NULL, $reply = NULL, $replyNome = NULL){
    $mail = new PHPMailer(); 
    $mail->SMTPAuth = true; 
    $mail->SMTPSecure = "tls"; 
    $mail->Host = MAILHOST; 
    $mail->Port = MAILPORT; 
    $mail->Username = MAILUSER; 
    $mail->Password = MAILPASS; 
    $mail->From = utf8_decode($from);
    $mail->FromName = utf8_decode($fromName); 
    if($reply != NULL){
    $mail->Subject = utf8_decode($subject); 
    $mail->Body = utf8_decode($message); 
    if($attachment != NULL){
        return true;
        return false;

Use this after the send function to see if any connection errors are revealed:

echo $mail->ErrorInfo;

Thanks for your answer Force Flow, but I dont get any message with that echo!

According to the PHPMailer documentation concerning the debugging of SMTP, you are required to switch the SMTP debugging mode on (since its default is off) by setting the SMTPDebug property to 1 or 2.

Try doing that and reply back here with what you get.

You have confirmed that the script is actually getting to the point when the email is being sent?