0
Hello! I’m having a problem using Phpmailer for an email sending via an external SMTP.
When I try to run the code, it always shows the following error at the end:
SMTP -> NOTICE: EOF Caught while checking if connectedThe following From address failed: [email protected] : Called Mail() without being Connected Mail error: The following From address failed: [email protected] : Called Mail() without being Connected
However, this only happens when I am using a Debian Linux VPS. When I run on Localhost on my Windows, the script works normally.
I’m using Zohomail’s SMTP, but I’ve tried it with Gmail as well, both work localhost, but none works on the machine.
require_once("phpmailer/class.phpmailer.php");
function smtpmailer($para, $de, $de_nome, $assunto, $corpo) {
global $error;
$mail = new PHPMailer();
$mail->IsSMTP(); // Ativar SMTP
$mail->SMTPDebug = 2; // Debugar: 1 = erros e mensagens, 2 = mensagens apenas
$mail->SMTPAuth = true; // Autenticação ativada
$mail->SMTPSecure = 'tls'; // TLS REQUERIDO
$mail->Host = 'smtp.zoho.com'; // SMTP utilizado
$mail->Port = 587; // A porta 587 deverá estar aberta em seu servidor
$mail->Username = "[email protected]";
$mail->Password = "senha";
$mail->SetFrom($de, $de_nome);
$mail->Subject = $assunto;
$mail->Body = $corpo;
$mail->AddAddress($para);
$mail->Sendmail = '/usr/sbin/sendmail';
if(!$mail->Send()) {
$error = 'Mail error: '.$mail->ErrorInfo;
return false;
} else {
$error = 'Mensagem enviada!';
return true;
}
}
Firewall is disabled. I am using the correct TLS ports. VPS is from OVH. Error log posted here: https://pastebin.com/Z734ZEws
Which version of TLS on the email server and which version of PHP on your HTTP server?
– Guilherme Nascimento
@Guilhermenascimento, the email server I have no knowledge of. But I was using Google’s TLS server as well. Already the PHP version is 7.0
– Arthur Henrique
Just for the record, on the php.net website they encourage you not to use php7.0 ... but more recent versions, it might be a bug so.
– Guilherme Nascimento