symfony / swiftmailer-bundle

Symfony Swiftmailer Bundle
https://symfony.com/swiftmailer-bundle
MIT License
1.56k stars 151 forks source link

Allow stream_options when using url #220

Closed amonares closed 4 years ago

amonares commented 6 years ago

Hi I was expected to allow stream_options when using url, but not.

This dont work:

swiftmailer:
  url: smtp://domain:465?encryption=ssl&auth_mode=login&username=the-user&password=the-pass
  spool: { type: 'memory' }
  stream_options:
    ssl:
      allow_self_signed: true
      verify_peer: false
      verify_peer_name: false

But this configuration work flawless:

swiftmailer:
  transport:        smtp
  username:         the-user
  password:         the-pass
  host:             domain
  port:             465
  encryption:       ssl
  auth-mode:        login
  spool: { type: 'memory' }
  stream_options:
    ssl:
      allow_self_signed: true
      verify_peer: false
      verify_peer_name: false

Or is there a form to pass the stream_options into the URL form.

Best regards, thanks for the work Álvaro Monares G.

Seb33300 commented 6 years ago

I am encountering the same issue.

The setStreamOptions is only called by the configureMailerTransport: https://github.com/symfony/swiftmailer-bundle/blob/master/DependencyInjection/SwiftmailerExtension.php#L192

I think it is missing in the SwiftmailerTransportFactory: https://github.com/symfony/swiftmailer-bundle/blob/master/DependencyInjection/SwiftmailerTransportFactory.php#L37

nreynis commented 5 years ago

configureMailerTransport is used only if no environment variable is used: https://github.com/symfony/swiftmailer-bundle/blob/master/DependencyInjection/SwiftmailerExtension.php#L96

I don't see why this should be the case. It's really annoying and force use to hardcode passwords is some environments.

fabpot commented 4 years ago

Closing as #289 should fix it.