Use environment variables in example SMTP config

Currently the email documentation provides an example of how to use the SMTP adapter in SwiftMailer, but this example hardcodes the password in the config file which is a security issue. It is possible to reference environment variables instead, so we should document and encourage this.
This commit is contained in:
Garion Herman 2019-04-29 09:53:22 +12:00 committed by Ingo Schommer
parent 212a99c904
commit 5c4367f46b

View File

@ -18,7 +18,7 @@ SilverStripe\Core\Injector\Injector:
Swift_Transport: Swift_SendmailTransport
```
For example, to use SMTP, create a file app/_config/email.yml:
For example, to use SMTP, create a file `app/_config/email.yml`:
```yml
---
@ -34,11 +34,13 @@ SilverStripe\Core\Injector\Injector:
Port: <port>
Encryption: tls
calls:
Username: [ setUsername, ['<username>'] ]
Password: [ setPassword, ['<password>'] ]
Username: [ setUsername, ['`APP_SMTP_USERNAME`'] ]
Password: [ setPassword, ['`APP_SMTP_PASSWORD`'] ]
AuthMode: [ setAuthMode, ['login'] ]
```
Note the usage of backticks to designate environment variables for the credentials - ensure you set these in your `.env` file or in your webserver configuration.
## Usage
### Sending plain text only