SMTP SSL verify

Sometimes, especially when testing email sending from test environments, you may encounter SSL issues, due to being unable to verify the peer, or self-signed certs.

with the swiftmailer transport, you can disable that checking via yaml:

SilverStripe\Core\Injector\Injector:
  Swift_Transport:
    class: Swift_SmtpTransport
    properties:
      Host: smtp.youmail.com
      Port: 587
      Encryption: tls
    calls:
      Username: [ setUsername, ['username'] ]
      Password: [ setPassword, ['password'] ]
      AuthMode: [ setAuthMode, ['login'] ]
      StreamOptions: 
        - setStreamOptions
        - args:
            ssl:
              allow_self_signed: true
              verify_peer: false
              verify_peer_name: false

It took a while to get that yaml syntax working

2 Likes

Yes it works, but in 2023 with CMS 4.13 there is error :confused:

[Emergency] Uncaught Error: Unknown named parameter $args

Not args, but options

 - options:
            ssl:
              allow_self_signed: true
              verify_peer: false
              verify_peer_name: false