Newer
Older
<img src="https://www.sgalinski.de/typo3conf/ext/project_theme/Resources/Public/Images/logo.svg" />
License: [GNU GPL, Version 2](https://www.gnu.org/licenses/gpl-2.0.html)
Repository: https://gitlab.sgalinski.de/typo3/sg_routes
Please report bugs here: https://gitlab.sgalinski.de/typo3/sg_routes
TYPO3 version: >7.6
## About
This extension provides an email templating service and mail queue functionality for all your TYPO3 extensions.
It also supports Templates in various languages, which can be managed in the backend.
Additionally sg_mail provides a finisher class for the [Formhandler](https://typo3.org/extensions/repository/view/formhandler) extension, making it possible to manage its templates in the backend.
## The Backend Module
After a successful Installation, you have a new module in the "WEB" section of your TYPO3 Backend.
Clicking on it loads the administration panel. Here you can create, update, delete and test your E-Mail templates.
## Usage
### Registering your Extension
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
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
}
}
}
```