Home » Php » php – How to disable "verify_peer" with Symfony Mailer component?

php – How to disable "verify_peer" with Symfony Mailer component?

Posted by: admin February 25, 2020 Leave a comment

Questions:

I’m configuring a mail server (postfix), with a self signed certificate, and it seems this self signed certificate is a problem for the Symfony Mailer component.

On Swiftmailer, using some configuration such as:

transport:
    stream_options:
        ssl:
            allow_self_signed: true

or

stream_options:
    ssl:
        verify_peer: false
        verify_peer_name: false

might fix it, but I can’t find a way to do that on mailer (I want to use the YAML configuration files if possible).

How to&Answers:

This option will been enabled when this pull request, which has been already merged into master, is tagged and released.

So it seems you would have to wait for the next Symfony release (4.4.5 or 5.0.5), and then you will able to do this by adding verify_peer to your Mailer DSN configuration.

Regularly, you’ll be able configure Mailer, you need only to create a MAILER_DSN environment variable (usually setting the value on one of your .env files is enough).

In a near future, you’ll be able to do this:

MAILER_DSN=smtp://user:[email protected]?verify_peer=false

But right now (as of 4.4.4 and 5.0.4) you can’t do this natively with Symfony Mailer.