Php Mailer error in hostgator

Asked

Viewed 5,645 times

3

This mistake you’re making I hope someone will help me please. Thank you

(Warning: stream_socket_enable_crypto(): Peer Certification CN='*.hostgator.com.br' Did not match expected CN='mail.systembit.com.br' in /home/syste058/public_html/Phpmailer/class.smtp.php on line 344 Error when sending e-mail: SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting)

PHP CODE

<?php
// Caminho da biblioteca PHPMailer
require 'PHPMailer/PHPMailerAutoload.php';

$Vai        = "name: $name\n\n\email: $email\n\n\assunto: $assunto\n\ntel: $tel\n\n\mensagem: $mensagem\n";

$servidor     = (isset($_POST['servidor-smtp'])) ? $_POST['servidor-smtp'] : 'mail.systembit.com.br';

$porta        = (isset($_POST['porta'])) ? $_POST['porta'] : '25';

$encriptacao  = (isset($_POST['encriptacao'])) ? $_POST['encriptacao'] : 'true';

$usuario      = (isset($_POST['usuario'])) ? $_POST['usuario'] :'[email protected]';

$senha        = (isset($_POST['senha'])) ? $_POST['senha'] : '****';

$name    = (isset($_POST['name'])) ? $_POST['name'] :'';

$email      = (isset($_POST['email'])) ? $_POST['email'] : '';

$tel      = (isset($_POST['tel'])) ? $_POST['tel'] : '';

$assunto      = (isset($_POST['assunto'])) ? $_POST['assunto'] : 'Mensagem do site System Bit';

$cabecalho    = "Email enviado por : ".$name." na data ".date('d-m-y H:i')."<br />\n";

$destinatario = (isset($_POST['destinatario'])) ? $_POST['destinatario']: '[email protected]';

$mensagem     = (isset($_POST['mensagem'])) ? $_POST['mensagem'] : '';


// Instância do objeto PHPMailer
$mail = new PHPMailer;

// Configura o charset do e-mail
$mail->CharSet = 'UTF-8';

// Configura para envio de e-mails usando SMTP
$mail->isSMTP();

// Servidor SMTP
$mail->Host = $servidor;

// Usar autenticação SMTP
$mail->SMTPAuth = true;

// Usuário da conta
$mail->Username = $usuario;

// Senha da conta
$mail->Password = $senha;

// Tipo de encriptação que será usado na conexão SMTP
$mail->SMTPSecure = $encriptacao;

// Porta do servidor SMTP
$mail->Port = $porta;

// Informa se vamos enviar mensagens usando HTML
$mail->IsHTML(true);

// Email do Remetente
$mail->From = $email;

// Nome do Remetente
$mail->FromName = $name;

// Endereço do e-mail do destinatário
$mail->addAddress($destinatario);

// Assunto do e-mail
$mail->Subject = $assunto;

// Mensagem que vai no corpo do e-mail
$mail->Body = $cabecalho.$email.$tel.$mensagem;

// Envia o e-mail e captura o sucesso ou erro
if($mail->Send()):
    echo "E-mail enviado com sucesso!";
else:
    echo "Erro ao enviar e-mail: {$mail->ErrorInfo}";

endif;
  • try to see the version of php used on the site, and also if the hostgator does not have any block referring to email form submissions and receipts like Locaweb, which has a system in which you can only send and receive if you have email of your own domain or hostgator

2 answers

5


PHP validates SSL certificates. Apparently you don’t have a valid certificate for mail.systembit.com.br in your system.

While the correct solution is to install a valid certificate, a work-Around most immediate is to disable validation:

$mail->SMTPOptions = array(
    'ssl' => array(
        'verify_peer' => false,
        'verify_peer_name' => false,
        'allow_self_signed' => true
    )
);

Sources:

  1. Soen - Phpmailer generates PHP Warning: stream_socket_enable_crypto(): Peer Certification Did not match expected
  2. Phpmailer - SSL Certificate is not verified
  • I put her in class.smtp.php on line 344? $mail->Smtpoptions = array( 'ssl' => array( 'verify_peer' => false, 'verify_peer_name' => false, 'allow_self_' => signed true ) );

  • You can apply these settings to any row after building the instance of PHPMailer and before calling $mail->Send();

  • Now it was ,Thank you very much brother have a good day

  • Hi Jeferson, I’m glad I helped. If this answer solved your problem don’t forget to accept it. Hugs.

-4

Guys after much testing I found out what this problem is in hostgator. It’s the fucking permissions in the folders. Put it in 755 and be happy. FDPS leave everything at 750

Browser other questions tagged

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