Inviting email addresses with "+" fails with an "Invalid Email Format" error #4138

Closed
opened 2026-02-21 18:04:54 -05:00 by yindo · 1 comment
Owner

Originally created by @yamitzky on GitHub (Jun 17, 2024).

Self Checks

  • This is only for bug report, if you would like to ask a question, please head to Discussions.
  • I have searched for existing issues search for existing issues, including closed ones.
  • I confirm that I am using English to submit this report (我已阅读并同意 Language Policy).
  • Please do not modify this template :) and fill in all the required fields.

Dify version

0.6.11

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

  • Navigate to Settings -> Members -> Add
  • Enter an email address with "+", such as test+test@example.com, and click "Send Invite"
  • A toast message saying "Invalid Email Format" appears

✔️ Expected Behavior

"Invitation link" is generated.

According to RFC 5322, the following characters are allowed: !#$%&'*+-/=?^_{|}~`, and the plus sign can be used in Gmail.

Actual Behavior

"Invalid Email Format" appears, and no link is generated.

Originally created by @yamitzky on GitHub (Jun 17, 2024). ### Self Checks - [X] This is only for bug report, if you would like to ask a question, please head to [Discussions](https://github.com/langgenius/dify/discussions/categories/general). - [X] I have searched for existing issues [search for existing issues](https://github.com/langgenius/dify/issues), including closed ones. - [X] I confirm that I am using English to submit this report (我已阅读并同意 [Language Policy](https://github.com/langgenius/dify/issues/1542)). - [X] Please do not modify this template :) and fill in all the required fields. ### Dify version 0.6.11 ### Cloud or Self Hosted Self Hosted (Docker) ### Steps to reproduce - Navigate to Settings -> Members -> Add - Enter an email address with "+", such as test+test@example.com, and click "Send Invite" - A toast message saying "Invalid Email Format" appears ### ✔️ Expected Behavior "Invitation link" is generated. According to RFC 5322, the following characters are allowed: !#$%&'*+-/=?^_{|}~`, and the plus sign can be used in Gmail. ### ❌ Actual Behavior "Invalid Email Format" appears, and no link is generated.
yindo added the 🐞 bug label 2026-02-21 18:04:54 -05:00
yindo closed this issue 2026-02-21 18:04:54 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Jun 17, 2024):

@yamitzky Hello there! I'm here to help you with any bugs, questions, or contributions you have for the repository. Let's tackle this issue together!

The issue is likely due to the emailRegex used in the InviteModal component, which might not be allowing the "+" character. To resolve this, you need to update the emailRegex to include the "+" character. Here is an example of a regular expression that allows the "+" character in email addresses:

const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;

Update the emailRegex in your InviteModal component as shown below:

import { emailRegex } from '@/config';

// Update the emailRegex to allow "+" character
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;

const handleSend = useCallback(async () => {
  if (emails.map((email: string) => emailRegex.test(email)).every(Boolean)) {
    try {
      const { result, invitation_results } = await inviteMember({
        url: '/workspaces/current/members/invite-email',
        body: { emails, role: role.name, language: locale },
      });
      if (result === 'success') {
        onCancel();
        onSend(invitation_results);
      }
    } catch (e) {}
  } else {
    notify({ type: 'error', message: t('common.members.emailInvalid') });
  }
}, [role, emails, notify, onCancel, onSend, t]);

By updating the emailRegex, the system should now correctly validate email addresses containing the "+" character and generate the invitation link as expected [1].

To continue talking to Dosu, mention @dosu.

@dosubot[bot] commented on GitHub (Jun 17, 2024): <!-- Greeting --> @yamitzky Hello there! I'm here to help you with any bugs, questions, or contributions you have for the repository. Let's tackle this issue together! <!-- Answer --> The issue is likely due to the `emailRegex` used in the `InviteModal` component, which might not be allowing the "+" character. To resolve this, you need to update the `emailRegex` to include the "+" character. Here is an example of a regular expression that allows the "+" character in email addresses: ```tsx const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/; ``` Update the `emailRegex` in your `InviteModal` component as shown below: ```tsx import { emailRegex } from '@/config'; // Update the emailRegex to allow "+" character const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/; const handleSend = useCallback(async () => { if (emails.map((email: string) => emailRegex.test(email)).every(Boolean)) { try { const { result, invitation_results } = await inviteMember({ url: '/workspaces/current/members/invite-email', body: { emails, role: role.name, language: locale }, }); if (result === 'success') { onCancel(); onSend(invitation_results); } } catch (e) {} } else { notify({ type: 'error', message: t('common.members.emailInvalid') }); } }, [role, emails, notify, onCancel, onSend, t]); ``` By updating the `emailRegex`, the system should now correctly validate email addresses containing the "+" character and generate the invitation link as expected <sup>[[1]](https://github.com/langgenius/dify/blob/main/web/app/components/header/account-setting/members-page/invite-modal/index.tsx)</sup>. <!-- Dosu Comment Footer --> *To continue talking to [Dosu](https://dosu.dev), mention @dosu.*
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#4138