DOCS Email docs and upgrade notes

This commit is contained in:
Daniel Hensby 2017-01-13 16:12:25 +00:00
parent c4972da37e
commit 9a00ead731
No known key found for this signature in database
GPG Key ID: B00D1E9767F0B06E
2 changed files with 28 additions and 2 deletions

View File

@ -38,7 +38,7 @@ to `*text*`).
<div class="info" markdown="1"> <div class="info" markdown="1">
The default HTML template for emails is named `GenericEmail` and is located in `framework/templates/SilverStripe/Email/`. The default HTML template for emails is named `GenericEmail` and is located in `framework/templates/SilverStripe/Email/`.
To customise this template, copy it to the `mysite/templates/Email/` folder or use `setTemplate` when you create the To customise this template, copy it to the `mysite/templates/Email/` folder or use `setHTMLTemplate` when you create the
`Email` instance. `Email` instance.
</div> </div>
@ -58,7 +58,7 @@ The PHP Logic..
```php ```php
$email = SilverStripe\Control\Email\Email::create() $email = SilverStripe\Control\Email\Email::create()
->setTemplate('Email\\MyCustomEmail') ->setHTMLTemplate('Email\\MyCustomEmail')
->setData(array( ->setData(array(
'Member' => Member::currentUser(), 'Member' => Member::currentUser(),
'Link'=> $link, 'Link'=> $link,
@ -79,6 +79,18 @@ As we've added a new template file (`MyCustomEmail`) make sure you clear the Sil
take affect. take affect.
</div> </div>
#### Custom plain templates
By default SilverStripe will generate a plain text representation of the email from the HTML body. However if you'd like
to specify your own own plaintext version/template you can use `$email->setPlainTemplate()` to render a custom view of
the plain email:
```php
$email = new Email();
$email->setPlainTemplate('MyPlanTemplate');
$this->send();
```
## Administrator Emails ## Administrator Emails
You can set the default sender address of emails through the `Email.admin_email` [configuration setting](/developer_guides/configuration). You can set the default sender address of emails through the `Email.admin_email` [configuration setting](/developer_guides/configuration).

View File

@ -15,6 +15,7 @@ guide developers in preparing existing 3.x code for compatibility with 4.0
* [ORM API](#overview-orm) * [ORM API](#overview-orm)
* [Filesystem API](#overview-filesystem) * [Filesystem API](#overview-filesystem)
* [Template and Form API](#overview-template) * [Template and Form API](#overview-template)
* [Email and Mailer](#overview-mailer)
* [Commit History](#commit-history) * [Commit History](#commit-history)
## <a name="overview"></a>Highlights of major changes ## <a name="overview"></a>Highlights of major changes
@ -1174,3 +1175,16 @@ handle field-level and form-level messages. This has the following properties:
* Removed `PermissionCheckboxSetField::getAssignedPermissionCodes()` (never implemented) * Removed `PermissionCheckboxSetField::getAssignedPermissionCodes()` (never implemented)
* `Requirements::delete_combined_files()` and `Requirements::delete_combined_files()` methods have been removed * `Requirements::delete_combined_files()` and `Requirements::delete_combined_files()` methods have been removed
as they are obsolete. as they are obsolete.
### <a name="overview-mailer"></a>Email and Mailer
* `Mailer` converted to an interface
* `SwfitMailer` added as new default mailer
* `Email` re-written to be powered by [SwiftMailer](https://github.com/swiftmailer/swiftmailer)
#### <a name="overview-orm-api"></a>Email Additions / Changes
* Default template body variable renamed from `$Body` to `$EmailContent`
* `$email->setTemplate()` renamed to `$email->setHTMLTemplate()`
* Added `$email->setPlainTemplate` for rendering plain versions of email