Skip to content

feat: Add confirmation email for form respondents#3289

Open
dtretyakov wants to merge 5 commits intonextcloud:mainfrom
dtretyakov:feat/confirmation-email
Open

feat: Add confirmation email for form respondents#3289
dtretyakov wants to merge 5 commits intonextcloud:mainfrom
dtretyakov:feat/confirmation-email

Conversation

@dtretyakov
Copy link
Copy Markdown

@dtretyakov dtretyakov commented Apr 14, 2026

Closes #525 - Send confirmation emails to form respondents after submission.

Features:

  • Add confirmation email settings (enabled, subject, body) to Form entity.
  • Implement email sending with placeholder replacement:
    • {formTitle}, {formDescription}
    • Field placeholders based on name or label (e.g. {name}, {email}).
  • Allow form creators to explicitly select the recipient email field when multiple email fields are present.
  • Add UI in Settings sidebar to configure confirmation emails and recipient selection.
  • Replace basic email validation with Nextcloud's internal IEmailValidator.
  • Integration with activity notifications and background jobs for file syncing.

Technical changes:

  • Database migration for new Form properties.
  • Enhanced FormsService with email sending logic and validation.
  • Extensive unit and integration tests covering the new functionality.
  • Updated API documentation and OpenAPI spec.

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 14, 2026

Codecov Report

❌ Patch coverage is 74.60317% with 32 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
lib/Migration/Version050301Date20260413233000.php 0.00% 25 Missing ⚠️
lib/Service/FormsService.php 92.63% 7 Missing ⚠️

📢 Thoughts on this report? Let us know!

@dtretyakov dtretyakov marked this pull request as ready for review April 14, 2026 07:10
@dtretyakov
Copy link
Copy Markdown
Author

@Chartman123 I also tried to streamline UX for the feature.

Now the form looks like that:

Снимок экрана 2026-04-14 в 09 04 36

@Chartman123
Copy link
Copy Markdown
Collaborator

@dtretyakov looks good :)

I'll ping the design specialists to see what they think about it :)

@dtretyakov dtretyakov force-pushed the feat/confirmation-email branch from b111145 to 9452b76 Compare April 14, 2026 07:28
@dtretyakov
Copy link
Copy Markdown
Author

OCP\Mail\IEmailValidator breaks backward compatibility for this PR. The interface is not available in nextcloud/ocp on stable31.

For app code here, IMailer::validateMailAddress() is the safer choice: it is already available across the supported server branches and covers the same validation use case without introducing a branch-specific compatibility break.

@Chartman123
Copy link
Copy Markdown
Collaborator

No problem, just ignore this. For the next release we will no longer support NC31

@dtretyakov dtretyakov force-pushed the feat/confirmation-email branch from 9452b76 to 363a0cb Compare April 18, 2026 21:15
Signed-off-by: Dmitry Tretyakov <dtretyakov@gmail.com>
@dtretyakov dtretyakov force-pushed the feat/confirmation-email branch from 363a0cb to 9cb9c09 Compare April 21, 2026 17:47
@dtretyakov
Copy link
Copy Markdown
Author

@Chartman123 the branch is rebased on the fresh main and uses OCP\Mail\IEmailValidator.
Please let me know if you're missing something to push it forward and make NC customers happier.

Copy link
Copy Markdown
Collaborator

@Chartman123 Chartman123 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did a quick review and found some parts that should be changed in my opinion.

Please also add the new fields to FormsMigrator.php.

Also not sure about the frontend part, especially in the sidebar as I'm no vue expert. I added @susnux and @pringelmann as reviewers :)

Btw no need to hurry, the next release is not yet directly around the corner. We'll get it merged once it's ready :)

Comment thread lib/Migration/Version050301Date20260413233000.php Outdated
Comment thread lib/Migration/Version050301Date20260413233000.php Outdated
Comment thread lib/Constants.php
];

public const EXTRA_SETTINGS_SHORT = [
'confirmationEmailRecipient' => ['boolean'],
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure, if we should add the extraSetting to the whole short question type or if we'd better have it only for *_SHORT_EMAIL. Otherwise it could also be set for e.g. number fields.

@susnux @pringelmann what do you think?

Comment thread lib/ResponseDefinitions.php
Comment thread src/components/SidebarTabs/SettingsSidebarTab.vue Outdated
Comment on lines +222 to +248
<NcNoteCard
v-if="hasConfirmationEmailRecipientConflict"
type="error"
:text="
t(
'forms',
'Only one email field can be used for confirmation emails. Select the recipient field below to fix this.',
)
" />
<NcNoteCard
v-else-if="emailQuestionCount === 0"
type="error"
:text="
t(
'forms',
'Add at least one email field before confirmation emails can be used.',
)
" />
<NcNoteCard
v-else-if="requiresConfirmationEmailRecipientSelection"
type="error"
:text="
t(
'forms',
'Select which email field should receive confirmation emails before finishing this setup.',
)
" />
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps you could only use one NcNoteCard for all errors and use a single computed prop that returns the error text based on the error?

Comment on lines +266 to +279
<select
:value="selectedConfirmationEmailQuestionId"
:disabled="locked || isSavingConfirmationEmailRecipient"
class="confirmation-email__select"
@change="onConfirmationEmailRecipientSelectionChange">
<option value="">
{{ t('forms', 'Select an email field') }}
</option>
<option
v-for="question in confirmationEmailQuestions"
:key="question.id"
:value="question.id">
{{ confirmationEmailQuestionLabel(question) }}
</option>
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not use NcSelect here? this would already bring the correct styling. Same for the other input fields

@Chartman123 Chartman123 added this to the 5.3 milestone Apr 21, 2026
dtretyakov and others added 4 commits April 22, 2026 10:08
Co-authored-by: Christian Hartmann <chris-hartmann@gmx.de>
Signed-off-by: Dmitry Tretyakov <dtretyakov@users.noreply.github.com>
Co-authored-by: Christian Hartmann <chris-hartmann@gmx.de>
Signed-off-by: Dmitry Tretyakov <dtretyakov@users.noreply.github.com>
Co-authored-by: Christian Hartmann <chris-hartmann@gmx.de>
Signed-off-by: Dmitry Tretyakov <dtretyakov@users.noreply.github.com>
Co-authored-by: Christian Hartmann <chris-hartmann@gmx.de>
Signed-off-by: Dmitry Tretyakov <dtretyakov@users.noreply.github.com>
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please also change the file name

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Confirmation mail for respondents

2 participants