0
I am not able to send e-mail by Phpmailer 5.1, I used the following class:
<?php
require_once(__DIR__.'/../../PHPMailer/class.phpmailer.php');
require_once(__DIR__.'/../../PHPMailer/class.smtp.php');
class Mailer extends PHPMailer
{
public function __construct()
{
$this->IsSMTP(true);
$this->SMTPAuth = true;
$this->Host = 'mail.example.com.br'; // Dados fictícios apenas para demonstração
$this->Port = 465;
$this->SMTPSecure = 'tls';
$this->Username = '[email protected]'; // Dados fictícios apenas para demonstração
$this->Password = 's5njsd12efasc4';
$this->IsHTML(true);
$this->CharSet = 'UTF-8';
$this->From = "[email protected]"; // Dados fictícios apenas para demonstração
$this->FromName = "Example"; // Dados fictícios apenas para demonstração
}
}
I’m using it this way:
$mail = new Mailer;
$mail->Subject = "Alerta";
$mail->MsgHTML('teste');
$mail->AddAddress('[email protected]'); // Dados fictícios apenas para demonstração
$mail->AddBCC("[email protected]"); // Dados fictícios apenas para demonstração
$mail->Send();
It always results in: Language string failed to load: tls
I have tested commenting on some lines:
Attempt 1:
// $this->SMTPSecure = 'tls';
Results in:
SMTP Error: Could not authenticate.
Attempt 2:
// $this->SMTPAuth = true;
// $this->SMTPSecure = 'tls';
Results in:
The following From address failed: ([email protected])
Attempt 3:
// $this->SMTPAuth = true;
Results in:
Language string failed to load: tls
Attempt 4:
$this->Port = 25;
Results in:
SMTP Error: Could not connect to SMTP host.
I don’t think it influences anything, but just to be clear I’m using local.
If you can help me I’ll be eternally grateful :)
UPDATE 29/04/2020
I also tested with Phpmailer 5.2.16, it turned blank, it is as if I had sent the email, but did not send, as no e-mail came in my e-mail. So I inserted some echo
in class errors class.phpmailer.php
and found the following mistake:
SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting
I upgraded Phpmailer to the latest version (6.1) via composer.json
, as per the tips, I activated the debug mode $this->SMTPDebug = SMTP::DEBUG_SERVER;
, the result is now being:
2020-04-29 14:09:11 SERVER -> CLIENT:
2020-04-29 14:09:11 CLIENT -> SERVER: EHLO 192.168.100.10
2020-04-29 14:09:11 SERVER -> CLIENT:
2020-04-29 14:09:11 SMTP ERROR: EHLO command failed:
2020-04-29 14:09:11 SMTP NOTICE: EOF caught while checking if connected
2020-04-29 14:09:11 SMTP Error: Could not connect to SMTP host.
2020-04-29 14:09:11 SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting