[SOLVED] Swiftmailer with TLS

Hello,

how can you setup Swiftmailer to use TLS encryption?

Would something like this be correct?

SwiftMailer:
transport:
type: ‘Swift_SmtpTransport’
options:
host: ‘mailserver’
port: 587
username: ‘user’
password: ‘password’
encryption: ‘tls’

Ciao,
Rene

Hi Rene,

I just compared it to a working instance (which uses SMTP via TLS too) and the configuration looks exactly the same. So, yes, this looks indeed correct.

(Only if you struggle to get it to work read on)


The swiftmailer-for-flow Package can’t really offer a detailed configuration reference, since it is just a wrapper and just hands over the mailer-specific configuration to Swift Mailer. The documentation itself points to Swift Mailer:

Further transports are available with Swift Mailer and can be used as well. Their options can be looked up the Swift Mailer documentation and they can be set by extrapolating from their setter method names (as in: setUsername() becomes username in the options.)

The relevant part of the swiftmailer documentation is IMHO not really a reference (as in “describes every option precisely”), but it has some valueable hints:

For SSL or TLS encryption to work your PHP installation must have appropriate OpenSSL transports wrappers. You can check if “tls” and/or “ssl” are present in your PHP installation by using the PHP function stream_get_transports().

The relevant setter method of Swift Mailer further suggests using tls or ssl (translated to the needs of the flow package, this is the configuration entry encryption: 'tls' )

Further things to look out:

  • proper user name (with / without @domain suffix as needed)
  • make sure your SMTP server instance allows sending mails using the given FROM address. Some UIs allow users to even enter a FROM address, whereas most SMTP servers instances will refuse to send mail “from” any address other than the authenticated users’ one.

@rbauer Could this be solved?

Yes. encryption: ‘tls’ did the trick.