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.

9b7f8bc40cb74e3368c9b70b4c814604?s=128

Georg Ringer

August 04, 2019
Tweet

Transcript

  1. Georg Ringer - TemplatedEmails T3DD19 Templated Emails TYPO3 Developer Days

    2019
  2. Georg Ringer - TemplatedEmails T3DD19 Agenda - My dream -

    About me - Symfony - Proposal & Examples - Questions & Feedback
  3. Georg Ringer - TemplatedEmails T3DD19 Generating nice mails sucks...

  4. Georg Ringer - TemplatedEmails T3DD19 Test-Mail from Install Tool

  5. 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
  6. Georg Ringer - TemplatedEmails T3DD19 Georg Ringer - Core Developer

    - Extension Developer studiomitte.com georg_ringer georgringer studiomitte studiomitte
  7. 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
  8. Georg Ringer - TemplatedEmails T3DD19 Who creates HTML mails?

  9. Georg Ringer - TemplatedEmails T3DD19 Who developed a MailService with

    Fluid StandaloneView?
  10. Georg Ringer - TemplatedEmails T3DD19 Who creates multi-language mails?

  11. Georg Ringer - TemplatedEmails T3DD19 symfony/mime

  12. Georg Ringer - TemplatedEmails T3DD19 Symfony/mime - Simple example $email

    = GeneralUtility::makeInstance(MailMessage::class); $email ->from('fabien@symfony.com') ->to('foo@example.com') ->cc('bar@example.com') ->bcc('baz@example.com') ->replyTo('fabien@symfony.com') ->priority(Email::PRIORITY_HIGH) ->subject('Important Notification') ->text('Lorem ipsum...') ->html('<h1>Lorem ipsum</h1> <p>...</p>') ;
  13. Georg Ringer - TemplatedEmails T3DD19

  14. Georg Ringer - TemplatedEmails T3DD19

  15. 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
  16. Georg Ringer - TemplatedEmails T3DD19 Migration - faster than drinking

    a coffee $mailMessage = GeneralUtility::makeInstance(MailMessage::class) ->to($recipient) ->from(new NamedAddress('demo@domain.tld', 'From')) ->subject('Subject') ->html('<html><body>html test content</body></html>') ->send(); $mailMessage = GeneralUtility::makeInstance(TemplatedMail::class) ->to($recipient) ->from(new NamedAddress('demo@domain.tld', 'From')) ->subject('Subject') ->htmlContent('html test content') ->send();
  17. Georg Ringer - TemplatedEmails T3DD19 API Examples

  18. Georg Ringer - TemplatedEmails T3DD19 API Example - Simple $templatedEmail

    = GeneralUtility::makeInstance(TemplatedEmail::class); $templatedEmail ->to('dummy@example.org') ->from(new NamedAddress('noreply@example.org', 'TYPO3')) ->subject('A mail') ->htmlContent('<h1>Hello</h1> an example') ->textContent('Hello' . LF . 'an example') ->send();
  19. Georg Ringer - TemplatedEmails T3DD19 API Example - Simple: Result

  20. Georg Ringer - TemplatedEmails T3DD19 API Example - Fluid file

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

    $templatedEmail = GeneralUtility::makeInstance(TemplatedEmail::class); $templatedEmail ->to('dummy@example.org') ->from(new NamedAddress('noreply@example.org', '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();
  22. 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>
  23. 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']
  24. 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/'
  25. Georg Ringer - TemplatedEmails T3DD19 Next steps - Get more

    feedback - Better default Template - More features (inline images) - Migrate into core - Release TER
  26. Georg Ringer - TemplatedEmails T3DD19

  27. Georg Ringer - TemplatedEmails T3DD19 What is missing?

  28. Georg Ringer - TemplatedEmails T3DD19 Who developed a MailService with

    Fluid StandaloneView?
  29. Georg Ringer - TemplatedEmails T3DD19 Multi-Language mails with sections?

  30. Georg Ringer - TemplatedEmails T3DD19