How to disable “verify_peer” with Symfony Mailer c

2020-03-23 05:44发布

问题:

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).

回答1:

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 (this was merged into the 5.1 branch, so it doesn't look like it's going to be available in the 4.x branch at all), 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:pass@localhost?verify_peer=false

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