Skip to content

TYPO3-extension: Subscribe and unsubscribe to tt_address, generate static Link to unsubscribe (to use in Newsletter), automatically delete unconfirmed subscribers

License

Notifications You must be signed in to change notification settings

Gregor-Agnes/newsletter_subscribe

Repository files navigation

Newsletter Subscribe for TYPO3

  • Subcribe and unsubscribe for newsletters for TYPO3 >= 9.5
  • Depends on tt_address
  • Scheduler task to delete unconfirmed subscribers after a while (since v3.1.0)

What does it do?

  • Provides a plugin to double optin subscribe
  • Provides a plugin to double optin unsubscribe
  • Provides field in tt_address to generate unsubscribe link in direct_mail mailings

Breaking in 5.0

  • If you use the default templates and styles you have to add the class form-input to input fields and form-checkbox to the checkboxes. Ther former approach overrode the appearance of every checkbox on pages, where the static template of this extension was included.

Caveats

This extension changes the behaviour of tt_address and disables the soft delete feature which means that deleted records are removed from the database directly instead of being marked as deleted.

This might lead to problems if you already have an existing set of records in the table tt_address.

To mitigate this behaviour you can purge all deleted records from tt_address.
Or you can reenable the original behaviour by adding this code to Configuration/TCA/Overrides/tt_address.php in your sitepackage:

$GLOBALS['TCA']['tt_address']['ctrl']['delete'] = 'deleted';

Removed hard deletion of tt_address records. Because of https://docs.typo3.org/m/typo3/reference-coreapi/main/en-us/ExtensionArchitecture/FileStructure/ExtTablesSql.html#auto-generated-structure the field "delete" wouldn't be generated otherwise. Use Scheduler Task to delete soft-deleted records instead.

Install

  • Install via extension manager or
  • Install via composer
  • Include static template

Configuration

Parameter Description Type, Validation Default
dataProtectionPage Uid of page with information about the data protection policy integer 1
adminEmail Email address in admin notification mails string, email, mandatory admin.name@domain.tld
adminName Name in admin notification mails string Your admin name
senderEmail Email address in confirmation mails string, email, mandatory noreply@domain.tld
senderName Name in confirmation mails string Your sender name
newsletterName Title of the newsletter / subscription list string Newsletter
showFields Additional fields to show in subscription form (gender,firstName,lastName,company).
email and dataProtection are always shown.
string null
subscribePageUid Uid of page with subscription form. Used for links in templates and mails. string null
useSimpleSpamPrevention
(Extension Configuration)
whether there should be a simple spam preventition using javascript and session (with session cookie) bool 1
spamTimeout time in seconds to wait before form gets rendered again if spam check fails int 5
useHCaptcha whether hCaptcha (https://www.hcaptcha.com/) should be used, needs further configuration bool 0
hCaptchaSiteKey hCaptcha site key, only if hCaptcha is used string 10000000-ffff-ffff-ffff-000000000001
hCaptchaSecretKey hCaptcha secret key, only if hCaptcha is used string 0x0000000000000000000000000000000000000000
sendAdminInfo whether the admin should get an info mail on every confirmation bool 0
sendPageNotFoundOnInvalidConfirmation whether a 404 is thrown, when an invilid confirmation link is clicked. Otherwise a hint is shown (already confirmed?). This option is new in 6.1 bool 1
mailTemplateRootPath path to the mail templates, root for different languages (e.g. en, de, dk) string EXT:newsletter_subscribe/Resources/Private/Templates/Mail/
mailLayoutRootPath path to the mail layouts used from the templates string EXT:core/Resources/Private/Layouts/
overrideFlexformSettingsIfEmpty Fields, which should be overridden from typosrcipt if left blank in the flexform (like in tx_news, thx to Georg Ringer!). string adminEmail, adminName, subscribePageUid, mailTemplateRootPath, dataProtectionPage, adminName, showFields, newsletterName

Site config (for nicer link in subscriber mails)

routeEnhancers:
  UnSubscribe:
    type: Extbase
    extension: NewsletterSubscribe
    plugin: Unsubscribe
    routes:
      -
        routePath: '/unsubscribe/{unsubscribe}/{uid}'
        _controller: 'Subscribe::unsubscribe'
        _arguments:
          unsubscribe: subscriptionHash
          uid: uid
  Subscribe:
    type: Extbase
    extension: NewsletterSubscribe
    plugin: Subscribe
    routes:
      -
        routePath: '/confirm/create'
        _controller: 'Subscribe::createConfirmation'
      -
        routePath: '/confirm/{confirm}/{uid}'
        _controller: 'Subscribe::doConfirm'
        _arguments:
          confirm: subscriptionHash
          uid: uid
      -
        routePath: '/unsubscribe/{unsubscribe}/{uid}'
        _controller: 'Subscribe::unsubscribe'
        _arguments:
          unsubscribe: subscriptionHash
          uid: uid

Unsubscribe link in direct_mail

  1. First add the field subscription_hash to the fields of direct mail in the extension configuration of direct mail: direct mail configuration
  2. Add the link in your mail template:
    <a href="http://www.domain.tld/page/unsubscribe/###USER_subscription_hash###/###USER_uid###">unsubscribe</a> where this unsubscribe/###USER_subscription_hash###/###USER_uid###" is the important part.
    Note: The subscribe plugin must be inserted on the page "page" in that url.

Salutation in direct_mail

  1. Add 'salutation' field (see above 'subscription_hash')
  2. Add ###USER_salutation### on the page

Scheduler Tasks / Console Commands

There are scheduler tasks / console commands available (TYPO3 v10 only) to fill empty database fields in tt_address:

  • newslettersubscribe:fillsalutation
    Updates the salutation field based on the sys_language_uid and gender fields of the tt_address records. The salutation can be configured via TypoScript.
  • newslettersubscribe:fillsubscriptionhash
    Updates the subscription_hash field. This is especially handy if there are subscriptions added manually in the TYPO3 backend or you have legacy data in tt_address. The subscription_hash is necessary for the unsubscribe link in direct_mail to work.

To do

  • creating ajax submit
  • update documentation