Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
S
sg_mail
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TYPO3
sg_mail
Commits
22382bd3
Commit
22382bd3
authored
7 years ago
by
Torsten Oppermann
Browse files
Options
Downloads
Patches
Plain Diff
[TASK] Update documentation wip
parent
ce83a7cd
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!3
New version 4 1
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
README.md
+68
-22
68 additions, 22 deletions
README.md
with
68 additions
and
22 deletions
README.md
+
68
−
22
View file @
22382bd3
...
@@ -21,53 +21,99 @@ Additionally sg_mail provides a finisher class for the [Formhandler](https://typ
...
@@ -21,53 +21,99 @@ Additionally sg_mail provides a finisher class for the [Formhandler](https://typ
## Usage
## Usage
### Registering your Extension
### Registering your Extension
To make sg_mail available for your extension, you have to register it inside your
**ext_localconf.php**
To register your extension with sg_mail, you need a
**Configuration File**
for each template you want to integrate.
by supplying a path string to an implementation of
**SGalinski\SgMail\Service\RegisterInterface**
with:
It needs be a
*.php*
file and has to be inside the Configuration folder
**typo3conf/ext/{your_extension}/Configuration**
of your extension.
The naming of the file should be in upper camel case, matching your template name.
*
your extension key
sg_mail will automatically parse valid configuration files of all extensions within your TYPO3 instance.
*
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**
:
Inside the file you have mandatory and optional settings you can define
:
A fully working example class can be found here:
**SGalinski\SgMail\Example\Register
**
**Mandatory
**
All you need to do to get the example to work is registering your class in
**ext_localconf.php**
with:
-
extension_key
Needed to associate this template with the appropriate extension,
\SGalinski\SgMail\Service\MailTemplateService::registerByFile('SGalinski\SgMail\Example\Register');
-
template_key
A unique identifier of your template.
-
description
A short description of your templates usage, displayed in the backend template editor. This should be a
**language label**
-
subject
The default mail subject used for this Template. Here you can also provide a language label.
-
markers
An array of placeholder variables. Are dynamically replaced by the appropriate values. If you don't want any markers, provide an empty array.
A marker needs to be structured as follows:
-
marker
The variables name used in your templates.
-
type
Here you can specify the variable type by using one of the constants in the
**\SGalinski\SgMail\Service\MailTemplateService**
class.
-
value
An example value of this marker. Also used for previewing your mails in the backend module.
-
description
A short text describing the purpose of this marker.
**Optional**
-
template_path
You can provide a path to your mail template that differs from the default path with this setting.
**Example:**
Your configuration file for the template "confirm_mail" should be
**../Configuration/ConfirmMail.php**
.
A possible ConfirmMail.php file could look like this:
return [
'extension_key' => 'sg_example',
'template_key' => 'confirm_mail',
'description' => 'LLL:EXT:sg_example/Resources/Private/Language/locallang.xlf:mail.confirm.description',
'subject' => 'LLL:EXT:sg_example/Resources/Private/Language/locallang.xlf:mail.confirm.subject',
'markers' => [
[
'marker' => 'username',
'type' => \SGalinski\SgMail\Service\MailTemplateService::MARKER_TYPE_STRING,
'value' => 'max.mustermann@example.org',
'description' => 'LLL:EXT:sg_energieportal/Resources/Private/Language/locallang.xlf:mail.marker.username'
],
.... // more markers
]
];
### Send an email with the MailTemplateService
### Send an email with the MailTemplateService
Basic Usage:
Basic Usage:
1.
Get an instance of MailTemplateService
1.
Get an instance of MailTemplateService
2.
Set all desired fields (i.e. setLanguage, setToAddresses, setTemplateName, setExtensionKey etc.)
2.
Provide the
**template_name**
,
**extension_key**
and marker array in the constructor
3.
Invoke the
**sendEmail()**
function
3.
Set or override all desired fields (i.e. setLanguage, setToAddresses, setTemplateName, setExtensionKey etc.)
4.
Invoke the
**sendEmail()**
function
Example:
Example:
// get an instance of the service
// get an instance of the service
/** @var MailTemplateService $mailService */
/** @var MailTemplateService $mailService */
$mailService = $this->objectManager->get(MailTemplateService::class);
$mailService = $this->objectManager->get(MailTemplateService::class, 'confirm_mail', sg_example', ['username' => $username]);
// set the extension key & template name (mandatory!)
$mailService->setExtensionKey('your_extension_key');
$mailService->setTemplateName($this->settings['templateName']);
// set all the custom fields, these fields all have fallbacks from your configuration or the code
$mailService->setFromName($this->settings['fromName']);
$mailService->setFromName($this->settings['fromName']);
$mailService->setFromAddress($this->settings['fromEmail']);
$mailService->setFromAddress($this->settings['fromEmail']);
$mailService->setToAddresses([$emailAddress]);
$mailService->setToAddresses([$emailAddress]);
$mailService->setIgnoreMailQueue(TRUE);
$mailService->setIgnoreMailQueue(TRUE);
$mailService->setMarkers(['link' => $uri]);
// set the pageId (mandatory since version 4.0!!!)
// set the pageId (mandatory since version 4.0!!!)
$mailService->setPid(123);
$mailService->setPid(123);
// set the proper language for the mail
// set the proper language for the mail
(not necessary if you want the default language)
$mailService->setLanguage($GLOBALS['TSFE']->config['config']['language']);
$mailService->setLanguage($GLOBALS['TSFE']->config['config']['language']);
// finally send the mail
// finally send the mail
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment