From bd1aa0a13f2ccab6a5414a5ad42f0a59ef9738ba Mon Sep 17 00:00:00 2001 From: Paul Ilea <paul@sgalinski.de> Date: Tue, 21 Mar 2017 16:57:36 +0200 Subject: [PATCH] [TASK] Added Documentation --- README.md | 70 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 00000000..906de7fd --- /dev/null +++ b/README.md @@ -0,0 +1,70 @@ +# sg_mail + +This extension provides an email templating service and mail queue for other extensions. +Templates in various languages can be managed in the backend. Additionally sg_mail provides a finisher class +for the Formhandler extension, making it possible to manage formhandler templates in the backend. + +## Registering your Extension/Plugin + +To integrate sg_mail available for your extension, you have to register it inside your **ext_localconf.php** +by supplying a path string to an implementation of **SGalinski\SgMail\Service\RegisterInterface** with: + +* your extension key +* a name for the template +* the path to your default template files (template files should be named *language_code*.template.html. Example: en.template.html) +* a brief description of the template (when is it used ?) +* the template markers(placeholder variables) +* the subjects for all templates. Here you have to use an associative array language_code => subject + +### Example : + +An example class can be found here: **SGalinski\SgMail\Example\Register** + +Register your class in **ext_localconf.php** with: + +```\SGalinski\SgMail\Service\MailTemplateService::registerByFile('SGalinski\SgMail\Example\Register');``` + +### Send an email with the MailTemplateService + +Basic Usage: + +1. Get an instance of MailTemplateService +2. Set all desired fields (i.e. setLanguage, setToAddresses, setTemplateName, setExtensionKey etc.) +3. Invoke the **sendEmail()** function + +You can also set the priority (setPriority function of the service) for your mails with the constants +of the **SGalinski\SgMail\Domain\Model\Mail** class. With the Flag **ignoreMailQueue** you can switch between +queueing your Mail(false) or immediately(true) sending it. + +* PRIORITY_LOWEST +* PRIORITY_LOW +* PRIORITY_MEDIUM +* PRIORITY_HIGH +* PRIORITY_HIGHEST + +The higher the priority, the more likely the mail will get send immediately (depending how "busy" the MailQueue is). + +## Using sg_mail with Formhandler + +In your **setup.ts** of your formhandler extension, you have to invoke the **FormhandlerFinisherService** of sg_mail. +This is done in a similar fashion as with the usual finisher classes. + +### Example of sg_formhandler_ordercard + +``` +finishers { + # Finisher_Mail sends emails to an admin and/or the user. + 1 { + class = SGalinski\SgMail\Service\FormhandlerFinisherService + config { + checkBinaryCrLf = message + template_key = order_card_admin + extension_key = sg_formhandler_ordercard + to_address = admin@sgalinski.de + from_address = info@sgalinski.de + from_name = sgalinski.de + ignore_mail_queue = TRUE + } + } +} +``` -- GitLab