Since SilverStripe 4 uses Swift Mailer for sending emails, you can easily activate SMTP support for it.
You just need to setup a project's email config file, e.g.
Using gmail as example, a configuration would look like:
--- Name: myemailconfig After: emailconfig Only: environment: 'live' --- SilverStripe\Core\Injector\Injector: Swift_Transport: class: Swift_SmtpTransport properties: Host: smtp.gmail.com Port: 587 Encryption: tls calls: Username: [ setUsername, ['[email protected]'] ] Password: [ setPassword, ['`EMAIL_SMTP_PASSWORD`'] ] AuthMode: [ setAuthMode, ['login'] ]
The password is configured here through
EMAIL_SMTP_PASSWORD, which will be defined in your
SS_DATABASE_CLASS="MySQLPDODatabase" SS_ENVIRONMENT_TYPE="live" SS_DATABASE_SERVER="…" SS_DATABASE_USERNAME="…" SS_DATABASE_PASSWORD="…" SS_DATABASE_NAME="…" EMAIL_SMTP_PASSWORD="…"
SilverStripe sends now emails via SMTP and gmail.
Note: I updated the article on 17th May 2018 using a better way to descripe smtp usage.