0

ECA: Cron Event - View - Message per Mail

I would like to send a notification by e-mail to a user when a certain event occurs. The event is then a view that outputs a content, this content is currently a table with several entries or the table is just empty if there is nothing current.

I have created a cronjob with ECA that analyses a view and writes the content of this view to the mail. At least in theory, because in practice the mail does not yet arrive regularly. It has already been sent, but not at the respective time of the cron.

Hence my question, what am I doing wrong at the moment?

As I said, the view simply outputs an HTML table. If there is content in the table, then the system should send out a mail. If the table has no entries, then in the best case it will not. This seems to work so far, if it sends out a mail at all.

That would be my ECA export:

uuid: 854bec77-51a2-4a86-bf06-07508024432b
langcode: en
status: true
dependencies:
  config:
    - field.field.node.agent_anlegen.body
    - field.field.node.article.body
    - field.field.node.bonus_anlegen.body
    - field.field.node.grund_anlegen.body
    - field.field.node.page.body
    - field.field.node.paragraphs_ief_example.body
    - field.storage.node.body
    - views.view.erinnerungsmodul_ansicht_einen_monat
  module:
    - eca_base
    - eca_render
id: process_tcsl0rh
modeller: bpmn_io
label: 'Erinnerungsmodul grafisch'
version: ''
weight: -10
events:
  Event_08nnbjr:
    plugin: 'eca_base:eca_cron'
    label: Cron
    configuration:
      frequency: '0 */1 * * *'
    successors:
      -
        id: Activity_0qsiv4k
        condition: ''
conditions: {  }
gateways: {  }
actions:
  Activity_0qsiv4k:
    plugin: 'eca_render_views:views'
    label: 'Views ausgeben'
    configuration:
      view_id: erinnerungsmodul_ansicht_einen_monat
      display_id: default
      arguments: ''
      name: ''
      token_name: viewergebnis
      weight: ''
      mode: append
    successors:
      -
        id: Activity_00bl874
        condition: ''
  Activity_00bl874:
    plugin: action_send_email_action
    label: 'Mail verschicken'
    configuration:
      recipient: [email protected]
      subject: 'Ich bin die Testnachricht'
      message: |-
        Ich bin die Testnachricht:

        [node:title]
        [user:account-name]
        [user:display-name] 
        [comment:body] 
        -----------------------------------
        [viewergebnis]
      replace_tokens: true
    successors: {  }

Sometimes I get the following error message in the log files, but I'm not sure what it means?

**Failed execution of Views ausgeben (Activity_0qsiv4k) from ECA Erinnerungsmodul grafisch (process_tcsl0rh) for event Drupal\eca_base\Event\CronEvent: Failed to start the session because headers have already been sent by "/xxx/http-foundation/Response.php" at line 384..\n\n#0**

Any help would be appreciated and if anyone has a template or similar function I would also be very grateful.

Supplement: So when I send the mail when the user logs in, it does so as it should. So the only thing that doesn't seem to work is the cron event. But what am I doing wrong? Thank you

Thnx Bavra

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.