error in sendSMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting

Asked

Viewed 2,260 times

0

Hello folks I am developing a project and will have a contact page, however this giving the following error:

error in sendSMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting

PS: I’m using the phpmailer plugin

php Mailer:

<?php

 /**
* descricao EmailEnviar
*
* @author adrianosites.com.br
*/
class EmailEnviar extends PHPMailer {


/**
 * inicia os dados de conexao com o host
 * 
 */
function __construct() {

    $this->isSMTP();
    $this->isHTML(true);
    $this->CharSet = 'UTF-8';
    $this->Port = 587;
    $this->SMTPDebug = 0;
    $this->SMTPSecure = "tls";  
    $this->Host = 'smtp.gmail.com';
    $this->SMTPAuth   = true;  
    $this->Username   = "[email protected]"; 
    $this->Password   = "xxxxxxxxxx";        // SMTP account password
    //$this->SetFrom('[email protected]', 'Adriano sites php 
    imoveis');
    $this->From  = '[email protected]';
    $this->FromName = 'Acordo Imóvel';


}

/**
 * 
 * @param type $destinatario
 * @param type $assunto
 * @param type $msg
 * 
 *  envia o email
 */
public function Enviar($destinatario,$assunto,$msg) {



    $this->Subject = $assunto;
    $this->addAddress($destinatario);
    $this->Body = $msg;


    if(parent::send()):

        parent::clearAllRecipients();
        else:

        echo 'erro no envio' . $this->ErrorInfo ;
    endif;


}

}

2 answers

0

You are using the Gmail server and using a Hotmail account, use a Gmail account, as in the example:

function __construct() {

    $this->isSMTP();
    $this->isHTML(true);
    $this->CharSet = 'UTF-8';
    $this->Port = 587;
    $this->SMTPDebug = 0;
    $this->SMTPSecure = "tls";  
    $this->Host = 'smtp.gmail.com';
    $this->SMTPAuth   = true;  
    $this->Username   = "[email protected]"; 
    $this->Password   = "xxxxxxxxxx";        // SMTP account password
    //$this->SetFrom('[email protected]', 'Adriano sites php 
    imoveis');
    $this->From  = '[email protected]';
    $this->FromName = 'Acordo Imóvel';


}

-1

Use port 465 and ssl security:

$this->Port = 465;<br/>
$this->SMTPSecure = 'ssl';  

Browser other questions tagged

You are not signed in. Login or sign up in order to post.