Sending SMTP Mails with SilverStripe 4

Since SilverStripe 4 uses Switf Mailer for sending emails, you can easily activate SMTP support for it.

First create a usable Swift_SmtpTransport object which contains all required smtp settings:

<?php

class MySmtpMailTransport extends Swift_SmtpTransport {

     function __construct() {
        parent::__construct('smtp.server.local', 465, 'ssl');
        $this
            ->setUsername('username')
            ->setPassword('password');
    }

}

In the next step register this class in your config.yml for the Injector:

---
Name: myemailconfig
After: emailconfig
---
SilverStripe\Core\Injector\Injector:
  Swift_Transport: MySmtpMailTransport

SilverStripe sends now emails via SMTP.