Phpmailer does not send hosted

Asked

Viewed 136 times

0

Hello guys I am developing a site, and it will have a contact page so I am using the plugin phpmailer, when it is locally it sends the email correctly, but when host the email does not send and gives the following message

/home/u692630104/public_html/app/Phpmailer.class.php

Code:

<?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-mail.outlook.com';
    $this->SMTPAuth   = true;  
    $this->Username   = "[email protected]"; 
    $this->Password   = "xxxxxxxxx";        // SMTP account password
    //$this->SetFrom('[email protected]', 'Acordo Imovel');
    $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;


}


 }
  • Have you checked with your hosting if they have no restriction on sending emails with php? I had a recent problem and had to change hosting because they didn’t have smtp support.

  • Gosh I don’t know, it’s just that I’m hosting for free at Hostinger just to see if there are no mistakes, then I’ll host at Ocaweb

  • I imagine the programming part is ok because it worked locally.

1 answer

0

The hosting (Hostinger) you are using blocks access to port 587 for free plan users. In any of the plans your code must work.

  • So whether or not Ocaweb works right?

  • It works. I’ve sent emails with smtp using their most basic plan.

Browser other questions tagged

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