diff --git a/docs/en/02_Developer_Guides/10_Email/index.md b/docs/en/02_Developer_Guides/10_Email/index.md index 9e80c3df8..7c317a6ab 100644 --- a/docs/en/02_Developer_Guides/10_Email/index.md +++ b/docs/en/02_Developer_Guides/10_Email/index.md @@ -38,7 +38,7 @@ to `*text*`).
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.
@@ -58,7 +58,7 @@ The PHP Logic.. ```php $email = SilverStripe\Control\Email\Email::create() - ->setTemplate('Email\\MyCustomEmail') + ->setHTMLTemplate('Email\\MyCustomEmail') ->setData(array( 'Member' => Member::currentUser(), 'Link'=> $link, @@ -79,6 +79,18 @@ As we've added a new template file (`MyCustomEmail`) make sure you clear the Sil take affect. +#### 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 You can set the default sender address of emails through the `Email.admin_email` [configuration setting](/developer_guides/configuration). diff --git a/docs/en/04_Changelogs/4.0.0.md b/docs/en/04_Changelogs/4.0.0.md index b8e83871d..d84743c5f 100644 --- a/docs/en/04_Changelogs/4.0.0.md +++ b/docs/en/04_Changelogs/4.0.0.md @@ -15,6 +15,7 @@ guide developers in preparing existing 3.x code for compatibility with 4.0 * [ORM API](#overview-orm) * [Filesystem API](#overview-filesystem) * [Template and Form API](#overview-template) + * [Email and Mailer](#overview-mailer) * [Commit History](#commit-history) ## 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) * `Requirements::delete_combined_files()` and `Requirements::delete_combined_files()` methods have been removed as they are obsolete. + +### 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) + + +#### 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