Problem

Can not use multiple recipients based on component. Steps to reproduce:
e-mail settings

  • Create a webform.
  • Add a selection component.
  • Create an e-mail with the following settings in the To-field: multiple recipients per selection option of the component, see attached screenshot.
  • The e-mail address values in the component field (marked with 2 in the screenshot) are saved with , (comma + space).
  • If you enter multiple e-mail addresses in the custom to-field (marked with 1 in the screenshot), the addresses are saved with , (comma without space)
  • Problem: the second e-mail address is invalid because of the leading space in contact@test.com.

Proposed resolution

  1. Save the e-mail addresses in the component mapping field comma separated only (without spaces).
  2. Trim the e-mail addresses when sending, to maintain backwards compatibility.

Comments

matthiasm11 created an issue. See original summary.

matthiasm11’s picture

Issue summary: View changes
matthiasm11’s picture

Issue summary: View changes
matthiasm11’s picture

Attached a patch, fixing part 2 of the proposed resolution.

liam morland’s picture

Status: Active » Needs review
asvira’s picture

Status: Needs review » Reviewed & tested by the community

Proposed patch resolves the issue. I confirm that both recipients receive mail after applying the patch.

liam morland’s picture

That fixes part 2 of the solution. There should be a fix for part 1 as well.

liam morland’s picture

Status: Reviewed & tested by the community » Needs work

Part 2 is fixed. Part 1 should be fixed as well.

asvira’s picture

Status: Needs work » Needs review

I have some doubts that we should implement part 1 of proposed solution. Seems that it would be enough if we implement either part 1 or part 2. As we implemented part 2, we do not have any issues with sending mails to multiple recipients. I reviewed code and tested - every address is trimmed when submission mail is going to be sent.

Saved whitespaces after comma do not break anything. One whitespace after comma is useful - it helps to show component value in human-friendly way and allows proper line breaks.

So, this issue can be considered as resolved.

I suggest we handle whitespaces after comma in addresses in separate issue (and comma in name, multiple spaces in name, spaces between name and address)

liam morland’s picture

Status: Needs review » Fixed

Yes, I agree.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.