Skip to content

EsmtpTransport does not honor tls false configuration #53545

@rvicinus

Description

@rvicinus

Symfony version(s) affected

7.0

Description

The constructor of the EsmtpTransport offers the boolean parameter "tls", but even if configured to false, it switches to an encrypted connection if the server supports tls. This is an issue because if you try to connect to localhost, the certificate can not match and the connection fails with the exception: "SSL routines::certificate verify failed"

How to reproduce

Test on a system which accepts mail on localhost port 25, and that support STARTTLS:

<?php
use Symfony\Component\Mime\Email;
use Symfony\Component\Mailer\Mailer;
use Symfony\Component\Mailer\Transport\Smtp\EsmtpTransport;

require_once 'vendor/autoload.php';

$email = (new Email())
            ->from('test@example.com')
            ->to('test@example.com')
            ->subject('Test E-Mail')
            ->text('Test!');

$transport = new EsmtpTransport('localhost', 25, false);
$mailer = new Mailer($transport);
$mailer->send($email);

Possible Solution

In my opinion, the correct solution would be to either honor the tls parameter or not to verify the certificate, if the host is localhost.

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions