From a2f850d65f09a9ac52643d3d62353d6acc5fce64 Mon Sep 17 00:00:00 2001 From: Steve Boyd Date: Tue, 24 Aug 2021 10:53:22 +1200 Subject: [PATCH] DOC Add email section to server requirements --- .../00_Getting_Started/00_Server_Requirements.md | 16 ++++++++++++++++ docs/en/02_Developer_Guides/10_Email/index.md | 14 ++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/docs/en/00_Getting_Started/00_Server_Requirements.md b/docs/en/00_Getting_Started/00_Server_Requirements.md index 9a5780fb5..878262158 100644 --- a/docs/en/00_Getting_Started/00_Server_Requirements.md +++ b/docs/en/00_Getting_Started/00_Server_Requirements.md @@ -248,6 +248,22 @@ Additionally, there are community supported guides for installing Silverstripe C * [Vagrant with silverstripe-australia/vagrant-environment](https://github.com/silverstripe-australia/vagrant-environment) * [Vagrant with BetterBrief/vagrant-skeleton](https://github.com/BetterBrief/vagrant-skeleton) +### Email + +Silverstripe CMS uses SwiftMailer to send email messages. New installations setup with silverstripe/installer are configured to use a `sendmail` found in `/usr/sbin/sendmail` or another location specified via configuration. Alternatively email can be configured to use SMTP or other mail transports instead of sendmail. + +You _must_ ensure emails are being sent from your _production_ environment. You can do this by testing that the ***Lost password*** form available at `/Security/lostpassword` sends an email to your inbox, or with the following code snippet that can be run via a `SilverStripe\Dev\BuildTask`: + +```php +$email = new SilverStripe\Control\Email\Email('no-reply@mydomain.com', 'myuser@gmail.com', 'My test subject', 'My email body text'); +$email->send(); +``` + +Using the code snippet above also tests that the ability to set the "from" address is working correctly. + +See the [email section](/developer_guides/email) for futher details, including how to set the administrator "from" email address, change the `sendmail` binary location and how to use SMTP or other mail transports instead of sendmail. + + ## PHP Requirements for older Silverstripe CMS releases {#php-support} Silverstripe CMS's PHP support has changed over time and if you are looking to upgrade PHP on your Silverstripe CMS site, this diff --git a/docs/en/02_Developer_Guides/10_Email/index.md b/docs/en/02_Developer_Guides/10_Email/index.md index 72f4274d9..15ed00fba 100644 --- a/docs/en/02_Developer_Guides/10_Email/index.md +++ b/docs/en/02_Developer_Guides/10_Email/index.md @@ -94,6 +94,18 @@ SilverStripe\Core\Injector\Injector: 0: '/usr/bin/env catchmail -t' ``` +### Testing that email works + +You _must_ ensure emails are being sent from your _production_ environment. You can do this by testing that the +***Lost password*** form available at `/Security/lostpassword` sends an email to your inbox, or with the following code snippet that can be run via a `SilverStripe\Dev\BuildTask`: + +```php +$email = new Email('no-reply@mydomain.com', 'myuser@gmail.com', 'My test subject', 'My email body text'); +$email->send(); +``` + +Using the code snippet above also tests that the ability to set the "from" address is working correctly. + ## Usage ### Sending plain text only @@ -201,6 +213,8 @@ Remember, setting a `from` address that doesn't come from your domain (such as t email marked as spam. If you want to send from another address think about using the `setReplyTo` method. [/alert] +You will also have to remove the `SS_SEND_ALL_EMAILS_FROM` environment variable if it is present. + ## Redirecting Emails There are several other [configuration settings](/developer_guides/configuration) to manipulate the email server.