Failed to send email with phpmailer

0

I use PHPMAILER on another site where it works perfectly. However, this same code does not allow me to send emails, it gives Sucesso and no error appears. I used the code $mail->SMTPDebug = 2; and I can not find any errors there.

Here is the code

require 'mail/PHPMailerAutoload.php';
    $mail = new PHPMailer();
    $mail->IsSMTP();   
    $mail->SMTPDebug = 2;  
    $mail->Host = "servidor";  //nome do servidor está oculto
    $mail->Port = 587;
    $mail->SMTPAuth = false;
    $mail->CharSet="utf-8";

    $mail->From = "email1";
    $mail->FromName = "Nome1";
    $mail->AddAddress("email2");
    $mail->IsHTML(true);

    $mail->Subject = "Taasd";
    $mail->Body    = $titulo;

    if(!$mail->Send()){
       echo "<script>console.log('".$mail->ErrorInfo."')</script>";
       exit;
    }else{
        echo "<script>console.log('Sucesso')</script>";
    } 
    
asked by anonymous 19.03.2018 / 18:19

1 answer

1

Nowadays, servers that send without authentication are rare. If your case really accepted, it would be port 25.

If you do not accept, you will have to enter the username and password.

Example structure and debug:

Failed to read a .php file (PHPMailer lib)

    
19.03.2018 / 18:38