Upgrade to Pro — share decks privately, control downloads, hide ads and more …

TemplatedEmails in TYPO3 - T3DD19

TemplatedEmails in TYPO3 - T3DD19

What if
- all emails of TYPO3 core would look nicer
- the layout could be adopted to fit the customer’s CI (e.g. emails from linkvalidator)
-EXT:form, EXT:powermail or any extension could use the same layouts

This slides present the upcoming changes to the TYPO3 Core 10 LTS which introduce an API for using fluid templates for emails.

Currently this is a working Proof of Concept which can be found at https://github.com/georgringer/templatedMail and https://review.typo3.org/c/Packages/TYPO3.CMS/+/61387.

Georg Ringer

August 04, 2019
Tweet

Other Decks in Technology

Transcript

  1. Georg Ringer - TemplatedEmails T3DD19 Agenda - My dream -

    About me - Symfony - Proposal & Examples - Questions & Feedback
  2. Georg Ringer - TemplatedEmails T3DD19 What if ... - all

    emails of TYPO3 core would look nicer - the layout could be adopted to fit the customer’s CI (e.g. emails from linkvalidator) - form, powermail or any extension could use the same layouts
  3. Georg Ringer - TemplatedEmails T3DD19 Georg Ringer - Core Developer

    - Extension Developer studiomitte.com georg_ringer georgringer studiomitte studiomitte
  4. Georg Ringer - TemplatedEmails T3DD19 AUTOSWITCHTOLISTVIEW BACKEND_DEBUG CANONICAL CHGALLERY CHGALLERYTTNEWS

    CHLOGINSKIN CHNEWSFEEDS CHNEWSSORT CONSTANTSEXTENDED DEPRECATIONLOGANALYZER DISABLECSH EVENTNEWS GDPR LOGGING MAILCHIMP MPOSSNEWSSORTING NEWS NEWSDIRSYNC NEWSEXTENDED NEWS_IMPORTICSXML PAGE_SPEED RGACCORDION RGCOUNTDOWN RGECARD RGFOLDERSELECTOR RGFORMVALIDATOR RGGOOGLEMAP RGHELPMODULE RGLINKCAPTURE RGMEDIAIMAGES RGMEDIAIMAGESTTNEWS RGMEDIALINKS RGMENU RGMOODALBOX RGNEWSIMG RGNEWSLINKS RGPOPUP RGSENDNEWS RGSLIDESHOW RGSMOOTHGALLERY RGSMOOTHGALLERYLINKS RGSMOOTHSCROLL RGTABS RGTEASER RGWALLPAPER SOCIALS SYS_MESSAGES SYS_NOTEPAD SYS_TODOS SYS_WORKFLOWS T3MONITORING T3MONITORING_CLIENT TTNEWSGENERICMARKERS
  5. Georg Ringer - TemplatedEmails T3DD19 Symfony/mime - Simple example $email

    = GeneralUtility::makeInstance(MailMessage::class); $email ->from('[email protected]') ->to('[email protected]') ->cc('[email protected]') ->bcc('[email protected]') ->replyTo('[email protected]') ->priority(Email::PRIORITY_HIGH) ->subject('Important Notification') ->text('Lorem ipsum...') ->html('<h1>Lorem ipsum</h1> <p>...</p>') ;
  6. Georg Ringer - TemplatedEmails T3DD19 Technical background - API on

    top of MailMessage (Symfony/Mime) - Planning for TYPO3 10 + as extension for 9 LTS (maybe 8 LTS) Links - https://github.com/georgringer/templatedMail - https://review.typo3.org/c/Packages/TYPO3.CMS/+/61387
  7. Georg Ringer - TemplatedEmails T3DD19 Migration - faster than drinking

    a coffee $mailMessage = GeneralUtility::makeInstance(MailMessage::class) ->to($recipient) ->from(new NamedAddress('[email protected]', 'From')) ->subject('Subject') ->html('<html><body>html test content</body></html>') ->send(); $mailMessage = GeneralUtility::makeInstance(TemplatedMail::class) ->to($recipient) ->from(new NamedAddress('[email protected]', 'From')) ->subject('Subject') ->htmlContent('html test content') ->send();
  8. Georg Ringer - TemplatedEmails T3DD19 API Example - Simple $templatedEmail

    = GeneralUtility::makeInstance(TemplatedEmail::class); $templatedEmail ->to('[email protected]') ->from(new NamedAddress('[email protected]', 'TYPO3')) ->subject('A mail') ->htmlContent('<h1>Hello</h1> an example') ->textContent('Hello' . LF . 'an example') ->send();
  9. Georg Ringer - TemplatedEmails T3DD19 API Example - Fluid file

    $templatedEmail = GeneralUtility::makeInstance(TemplatedEmail::class); $templatedEmail ->to('[email protected]') ->from(new NamedAddress('[email protected]', 'TYPO3')) ->subject('A mail') ->context(['title' => 'My title']) ->htmlTemplateFile('EXT:templatedmail/.../Example.html') ->send();
  10. Georg Ringer - TemplatedEmails T3DD19 API Example - Custom Layouts

    $templatedEmail = GeneralUtility::makeInstance(TemplatedEmail::class); $templatedEmail ->to('[email protected]') ->from(new NamedAddress('[email protected]', 'TYPO3')) ->subject('A mail') ->setTemplateRootPaths(['EXT:dummy/Resources/Private/Templates/']) ->setLayoutRootPaths(['EXT:dummy/Resources/Private/Layouts/']) ->context(['title' => 'My title']) ->htmlByTemplate('Examples/Simple') ->textByTemplate('Examples/Simple') ->send();
  11. Georg Ringer - TemplatedEmails T3DD19 API Example - MultiLanguage $templatedEmail

    = GeneralUtility::makeInstance(TemplatedEmail::class); $templatedEmail ->subject('A mail') ->setLanguage('de') ->context(['title' => 'My title']) ->htmlTemplateFile('EXT:templatedmail/.../Examples/Example.html') ->send(); <f:section name="content"> {f:translate(languageKey:defaults.language,key:'LLL:EXT:ext/dummy.xlf:label)} </f:section>
  12. Georg Ringer - TemplatedEmails T3DD19 API Defaults - Site name

    - IP address - Global date & time configuration $GLOBALS['TYPO3_CONF_VARS']['SYS']['ddmmyy'] $GLOBALS['TYPO3_CONF_VARS']['SYS']['hhmm']
  13. Georg Ringer - TemplatedEmails T3DD19 Configuration within Site yaml templatedEmail:

    templateRootPaths: - 'EXT:templatedmail/Resources/Private/Templates/' partialRootPaths: - 'EXT:templatedmail/Resources/Private/Partials/' layoutRootPaths: - 'EXT:templatedmail/Resources/Private/Layouts/'
  14. Georg Ringer - TemplatedEmails T3DD19 Next steps - Get more

    feedback - Better default Template - More features (inline images) - Migrate into core - Release TER