Hello everyone,
I am facing an issue with sending emails after starting to migrate my clients to Hestia. I have the following PHP code that assembles and sends emails using the Zend Framework:
<?php
namespace Base\Helper;
use Zend\Mail\Transport\Smtp as SmtpTransport;
use Zend\Mail\Transport\SmtpOptions;
use Zend\Mail\Message;
use Zend\Mime\Message as MimeMessage;
use Zend\Mime\Part as MimePart;
class EmailMail
{
function emailMail($nomeCliente, $emailCliente, $emailEnvio, $assunto, $texto, $configSmtp)
{
$html = new MimePart($texto);
$html->type = "text/html";
$body = new MimeMessage();
$body->setParts([$html]);
$mail = new Message();
$mail->setBody($body);
$mail->setFrom($emailCliente, $nomeCliente);
$mail->addTo($emailEnvio, $emailEnvio);
$mail->setSubject($assunto);
$transport = new SmtpTransport();
$options = new SmtpOptions([
'name' => $configSmtp[0]->getSmtp(),
'host' => $configSmtp[0]->getHost(),
'port' => 587,
'connection_class' => 'login',
'connection_config' => [
'username' => $configSmtp[0]->getUser(),
'password' => $configSmtp[0]->getPassword(),
'use_complete_quit' => false,
'ssl' => 'tls',
],
]);
$transport->setOptions($options);
try {
$transport->send($mail);
return 1;
} catch (\Zend\Mail\Transport\Exception\ExceptionInterface $e) {
var_dump($e->getMessage());
exit;
return 2;
}
}
}
?>
I have enabled the
extension=php_openssl.dll
in PHP and restarted Apache, but the problem persists.
Previously, this code worked on VestaCp without requiring the following lines:
'port' => 587,
'ssl' => 'tls',
I have many clients using this method, and I don’t want to compromise the security of the server. If necessary, I will make the changes for all my clients.
The error message I receive is:
Unable to connect via TLS
Could anyone guide me on possible Exim configurations or adjustments to the code to resolve this issue? I have tried disabling the firewall but to no avail.
Thank you in advance for any help.