No confirmation email sent after submission

Created on 29 August 2023, over 1 year ago

Problem/Motivation

the confirmation email doesn't send to the user to confirm. no error log.

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Active

Version

1.0

Component

Code

Created by

🇿🇦South Africa abedmatini

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @abedmatini
  • Issue was unassigned.
  • Status changed to Needs review over 1 year ago
  • 🇮🇳India viren18febs

    Hi @abedmatini

    I have check the above issue in Drupal 9.5 & it is working as expected. may be you miss the email handlers for handle the email confirmation. I have attached screenshots for your reference.

  • Status changed to Postponed: needs info 6 months ago
  • Status changed to Closed: works as designed 3 months ago
  • Status changed to Needs work 20 days ago
  • 🇵🇱Poland piotrsmykaj

    I noticed the same issue, which happens in a multi-step form or when the Preview page is enabled. In this case, the submission gets the draft_created state only in the first step of the form. Going through the next steps, Preview page, or when submission is submitted, the user will get the draft_updated state, but the email handler expects to have draft_created so in the method below, the condition will not pass and $this->sendMessage() will not be executed.

    class EmailConfirmationWebformHandler extends EmailWebformHandler {
    
    /**
       * {@inheritdoc}
       */
      public function defaultConfiguration() {
        return [
          'states' => [WebformSubmissionInterface::STATE_DRAFT_CREATED],
    
      [...]
    
      /**
       * {@inheritdoc}
       */
      public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
        $form = parent::buildConfigurationForm($form, $form_state);
    
        $form['additional']['states']['#default_value'] = [WebformSubmissionInterface::STATE_DRAFT_CREATED];
        $form['additional']['states']['#access'] = FALSE;
    

    WebformSubmission->presave() the place where "created" is only set on the first step and the "changed" value is set on every page:

        // Set created.
        if (!$this->created->value) {
          $this->created->value = $request_time;
        }
    
        // Set changed.
        $this->changed->value = $request_time;
    

    WebformSubmission->getState() the cause why the draft_updated state is returned:

        elseif ($this->isDraft()) {
          return ($this->created->value === $this->changed->value) ? WebformSubmissionInterface::STATE_DRAFT_CREATED : WebformSubmissionInterface::STATE_DRAFT_UPDATED;
        }
    

    EmailWebformHandler->postSave() here the configuration expects draft_created, but submission returns the draft_updated:

      public function postSave(WebformSubmissionInterface $webform_submission, $update = TRUE) {
        $state = $webform_submission->getWebform()->getSetting('results_disabled') ? WebformSubmissionInterface::STATE_COMPLETED : $webform_submission->getState();
        if ($this->configuration['states'] && in_array($state, $this->configuration['states'])) {
          $message = $this->getMessage($webform_submission);
          $this->sendMessage($webform_submission, $message);
        }
      }
    
  • Pipeline finished with Success
    20 days ago
    Total: 145s
    #450362
  • Pipeline finished with Skipped
    12 days ago
    #457299
Production build 0.71.5 2024