Problem/Motivation
It is not possible at the moment to send an email to multiple recipients without assigning multiple actions to a trigger.
Steps to reproduce
1. Install the Drupal Instance
2. Enable the Actions module
3. Go to configuration->Actions
4. Than Choose the Send email option in the dropdown option and Click the create button
5. Add the Title and Enter Multiple recipients e-mail address with comma separated. You can able to reproduce the issue.
Proposed resolution
Allows a comma separated list of email addresses to be used (rather than forcing a single value) by:
- splitting the string in "Recipient email address" field on boundaries formed by comma (,) or comma + space (, )
- iterating over recipients with foreach ($recipients as $recipient)
or similar.
Remaining tasks
- Code review
Before/after behavior
Before:
After:
API changes
Data model changes
Release notes snippet
Comment | File | Size | Author |
---|---|---|---|
#71 | 284036-afterpatch.png | 127.49 KB | gaurav-mathur |
#71 | 284036-beforepatch.png | 111.95 KB | gaurav-mathur |
#69 | actions - after_patch.png | 228.61 KB | DeepaliJ |
#69 | actions - before_patch.png | 222.89 KB | DeepaliJ |
#68 | 284036-68.patch | 3.24 KB | rishabh064 |
|
Issue fork drupal-284036
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #1
stowell48 CreditAttribution: stowell48 commentedIs there a patch out that will allow this for drupal 6.x?
Comment #2
wintervanilla CreditAttribution: wintervanilla commentedI'd also love to see this functionality! Has anyone worked out a solution for this in 6.x?
Comment #3
crifi CreditAttribution: crifi commentedI would also like this feature, so let's commit a new patch. The patch doesn't consider the default language of more than one user. Should we always send in the default site language for more than one user?
Or split the mail recipients and send mails separately? This can be a problem with the load...
Comment #4
crifi CreditAttribution: crifi commentedA D6 backport you can find here #572190: Allow multiple recipients in email actions.
Comment #6
bfroehle CreditAttribution: bfroehle commentedThis seems problematic -- I think you'd have to do a
foreach ($recipients as $recipient)
or similar here.Powered by Dreditor.
Comment #7
crifi CreditAttribution: crifi commentedThanks bfroehle, but the problem is a false positive test, because I renamed the variable "recipient" to the plural "recipients". I don't know if this is allowed, but i have now adapt the test against my patch, so it can proof the recipients vars correctly.
But the point you suggested is still open. I don't know if it is useful to load the language for every recipient and send mails separately.
Comment #8
bfroehle CreditAttribution: bfroehle commentedComment in #6 still stands..
Also... I think at this point it's too late to rename 'recipient' to 'recipients' in any way, as some contributed modules might be using it...
But overloading 'recipient' to allow multiple emails might be okay.
Comment #9
crifi CreditAttribution: crifi commentedOkay so under the presumption that users would not use the action function as mass mail service (performance problem), I patch this with a foreach for individual user language support.
And there are two versions now:
D8) For code consistence and coding standard we rename the var "recipient" into the plural in the next major release of Drupal.
D7) For compatibility to contributed modules we hold the var name "recipient" in all other versions.
Comment #10
crifi CreditAttribution: crifi commentedSet it to need review for automatic testing...
Comment #11
crifi CreditAttribution: crifi commentedD8 branches seems to be ignored for testing, so let's take it back to D7 first. :(
Comment #12
benanderson CreditAttribution: benanderson commentedsubscribe
Comment #13
crifi CreditAttribution: crifi commentedMoving this to D8 list...
Comment #14
mxhThe send-email action should be fixed soon in future versions of both D7 and D8. Multiple recipients in one field is a typical use-case. I don't know why there is so little discussion about it.
Therefore, also tokens which supply multiple values should be supported in the recipients field.
In D6 there was the 'send *tokenized* email' action available delivered by Token Actions module, which did the job right (-> allowing multiple recipients). Unfortunately this module has been removed since the actions are supported "by core".
So the core action should support it too. Except of mass mailers, which are too big for the need here, i couldn't find an alternative action out-of-the box.
If there is no interest in fixing this problem, please tell me, so i will develop a module for a send-email action allowing multiple recipients the next time.
Comment #15
justindodge CreditAttribution: justindodge commented+1 Hoping to see this functionality get committed..
Comment #16
Itmman CreditAttribution: Itmman commentedWondering how to send and e-mail notification to site editors (3-4 people)
Comment #17
mxh#16: if you have at least only 3 - 4 editors to notify, and they're always the same people, you could just configure 4 single system send email actions for every editor. In the recipient field, you'll just type in the static and valid email value.
Then you would have 4 actions like "inform mr. xy about this content".
If this is more complicated, like there are dynamic editor groups, or every node has several defined email adresses to notify, then timtowtdi. Let me give you a summary.
Warning: These solutions should only be interesting if there is no "mass-mail" sending.
1. quick, effective, but NOT recommended:
You are now able to configure system send email actions, where the recipient field is not being validated.
Good: Multiple recipients, also can be defined by any token. If token has no ":mail" suffix, you should use email fields so a validation exists on node editing *
Bad: No validation; modified core -> self-explanatory.
2. quick, partially effective (sill not any token usable), better than 1.:
Now it's possible to configure system send email actions with multiple recipients defined by valid static email value or tokens with suffix ":mail".
Good: Validation still exists.
Bad: Modified core; unfortunately no other tokens can be used for the recipient field value but with ":mail" suffix.
3. not so quick, but effective, for me the best solution at this time:
Create an own module, see Creating Drupal 7.x Modules Guide if you're not familiar with writing modules.
This module will register an alternative send email action without validation. Below this post you'll see an example snippet how you could implement this. Unfortunately, I don't have the time to contribute a whole project, also I don't want to produce 'almost duplicate' modules, since this one here is very familiar with the system send email action. But I hope the code below also helps you out.
Good: No core modification; you can use any token.
Bad: No validation. You must be sure that the recipient field will get valid email adresses. Therefore, email fields can help you out * .
This is a possibility to implement an alternative send email action:
* If you want to use email fields with multiple values, you should set the correct default token format. See http://drupal.org/node/1459982 for further instructions.
Comment #18
naxoc CreditAttribution: naxoc commented#9: D8-284036-9.patch queued for re-testing.
Comment #22
jhedstromThis hasn't been touched in quite some time. Is it still relevant in 8.x?
Comment #30
Albert Volkman CreditAttribution: Albert Volkman commentedThis is still happening in 8.8.2
Comment #32
Nathaniel CreditAttribution: Nathaniel commentedThis seems like a bug or regression at this point (or maybe this is a different issue?).
1. Install Drupal core standard, enable Actions module.
2. Click "Configure" link for Actions module.
3. Under "CREATE AN ADVANCED ACTION" select "Send email" and click create.
4. Fill out the fields. In the "Recipient email address" field enter multiple email addresses separated by a comma.
5. Click save.
The field description says: "Separate recipients with a comma." When clicking save an error message pops up and it wont save.
Error message:
Enter a valid email address or use a token email address such as [node:author:mail].
Note that it does seem to work with multiple tokens: [node:author:mail], [comment:author:mail]. Or even a combination of email addresses and tokens, but NOT with multiple email addresses.
core/lib/Drupal/Core/Action/Plugin/Action/EmailAction.php
Comment #33
tanubansal CreditAttribution: tanubansal at Salsa Digital commentedTested with the latest patch and its working fine
This can be moved to RTBC
Comment #36
vikashsoni CreditAttribution: vikashsoni as a volunteer and at Zyxware Technologies commentedTested with #32 patch working fine after patch we able to add multiple coma separated email field instead of token email value for ref sharing screenshot
Comment #37
quietone CreditAttribution: quietone as a volunteer commented@vikashsoni, the previous comment added screenshots of the latest patch, there is no need to add another set which creates noise in the issue. Therefor, credit has been removed per How is credit granted for Drupal core issues.
This will need a test, adding tag.
This also needs an issue summary update, see Write an issue summary for an existing issue for guidance. It also needs steps to reproduce. A skim of the isseu and there are some in #32.
Updating the Issue summary is a suitable novice task, adding tag.
Comment #40
Janner CreditAttribution: Janner commented#32 worked for me, enabling me to get the send email action working as desired in the new ECA: Event - Condition - Action module.
Comment #41
eleonelTest attached.
Comment #42
Manibharathi E R CreditAttribution: Manibharathi E R at Srijan | A Material+ Company for Srijan | A Material+ Company commentedPatch #41 applied successfully on Drupal 9.5.x.
Steps to Reproduce:
1. Install the Drupal Instance
2. Enable the Actions module
3. Go to configuration->Actions
4. Than Choose the Send email option in the dropdown option and Click the create button
5. Add the Title and Enter Multiple recipients e-mail address with comma separated. You can able to reproduce the issue.
Test Results:
After adding the patch able to add multiple email address.
Comment #43
lucasscComment #44
lucasscI successfully applied patch #41 (284036-41.patch) for Drupal 9.5.x and 10.0.x using the Steps to Reproduce in #42.
The action with multiple email address has been successfully saved in both versions.
It's not a big deal but I noticed the description has spaces after commas, enter with these spaces I got an error message. (see spacing_error.png). I wonder if this might confuse new users...
Comment #45
ashishsingh27 CreditAttribution: ashishsingh27 at Intelliswift commentedComment #46
ashishsingh27 CreditAttribution: ashishsingh27 at Intelliswift commentedHi,
I applied the patch and was able to send to multiple email address.
But, As mentioned by @lucassc when tried to enter email with spaces got an error message.
attaching the patch to fix the spaces error.
Comment #47
ashishsingh27 CreditAttribution: ashishsingh27 at Intelliswift commentedComment #48
ashishsingh27 CreditAttribution: ashishsingh27 at Intelliswift commentedattaching inter-diff for 41-46.
Comment #49
ashishsingh27 CreditAttribution: ashishsingh27 at Intelliswift commentedI checked the patch on #46 again and found that I made mistake with EmailActionTest.php.
Attaching the fixed patch.
also, Attaching interdiff with 41-49.
Comment #50
gquisini CreditAttribution: gquisini at CI&T commentedI'll be reviewing.
Comment #51
gquisini CreditAttribution: gquisini at CI&T commentedOK,
I applied the #49 patch and following #42 steps
I was able to enter multiple recipients with/without spaces after commas.
Comment #53
reenaraghavan CreditAttribution: reenaraghavan as a volunteer and at QED42 commentedI will work on this issue.
Comment #54
reenaraghavan CreditAttribution: reenaraghavan as a volunteer and at QED42 commentedComment #55
gquisini CreditAttribution: gquisini at CI&T commentedI think we can switch to RTBC, since in the latest tests, everything is working and the problem reported in #52 is with ckeditor tests.
Comment #56
vinaymahale CreditAttribution: vinaymahale as a volunteer and at SJ Innovation LLC commentedPatch #49 works for me on D9.5.x-dev
Configuration before applying patch:
Configuration after applying patch:
Looks good to merge!
Comment #57
quietone CreditAttribution: quietone at PreviousNext commentedWhen setting an issue to RTBC remember to check the tags for tasks that still need to be done. This one is tagged for an Issue Summary update (asked for in #37) and that still needs to be done. I have added the template to help that along. Also, patches to Drupal need a core review before commit. I see a fair bit of testing in the comment but no evidence of code review.
There are several steps, or gates, that an issue must pass before it is marked RTBC. For most issues following step 10 in the Review a patch or merge request task of the Contributor guide is sufficient. The complete list of core gates has more topics. Also, check the tags on the issue and make sure they are complete.
@vinaymahale, adding screenshots to an issue that is RTBC is not needed. Therefor, I am removing credit per How is credit granted for Drupal core issues.
Comment #58
lucasscAdded Steps to reproduce, Proposed resolution, Remaining tasks and Before/after behavior in the IS.
Comment #59
lucasscPatch #49 needs review.
Comment #61
Aamir M CreditAttribution: Aamir M at QED42 for Drupal India Association commentedComment #62
Aamir M CreditAttribution: Aamir M at QED42 for Drupal India Association commentedPatch #49 was applied successfully and mentioned issue was also resolved.
Testing Steps:
1. Install the Drupal Instance
2. Enable the Actions module
3. Go to configuration->Actions
4. Than Choose the Send email option in the dropdown option and Click the Create button
5. Add the Title and Enter Multiple recipients' e-mail addresses with comma separated. You can able to reproduce the issue.
6. Observe its throwing error and Multiple recipients' e-mail addresses not saved
7. Apply the patch and follow the same steps as mentioned above
8. Now observe Multiple recipients' e-mail addresses saved successfully
9. No error is displayed
Results:
The Multiple recipients' e-mail addresses were saved successfully after applying the patch.
Looks good to me.
Can be moved to RTBC
RTBC+1
Comment #63
Manoj Raj.R CreditAttribution: Manoj Raj.R as a volunteer and at ITT Digital commentedI applied the #49 patch and looks good for me.
Thanks
Comment #64
Sivaji_Ganesh_Jojodae CreditAttribution: Sivaji_Ganesh_Jojodae as a volunteer and commentedPatch re-rolled.
Removed the redundant calls to explode,
and using array_filter() and array_map() instead.
Comment #65
Anchal_gupta CreditAttribution: Anchal_gupta at Srijan | A Material+ Company for Drupal India Association commentedI haved fixed cs error. Please review it
Comment #66
Sivaji_Ganesh_Jojodae CreditAttribution: Sivaji_Ganesh_Jojodae as a volunteer and commentedPatch #65 seems to have other changes as well.
Comment #67
pooja saraah CreditAttribution: pooja saraah at Srijan | A Material+ Company for Drupal India Association commentedFixed failed commands on #66
Comment #68
rishabh064 CreditAttribution: rishabh064 at OpenSense Labs for DrupalFit commentedAdded fix for #67
Comment #69
DeepaliJ CreditAttribution: DeepaliJ at Salsa Digital commentedPatch #68 was applied successfully on 10.1.x-dev
The issue has been resolved and working fine.
The Multiple recipients' e-mail addresses were saved successfully after applying the patch.
Before Patch:
After Patch:
RTBC +1
Comment #70
gaurav-mathur CreditAttribution: gaurav-mathur at Dotsquares Ltd. commentedComment #71
gaurav-mathur CreditAttribution: gaurav-mathur at Dotsquares Ltd. commentedSuccessfully Applied patch #68 for Drupal 10.1.x version and working fine, Adding screenshots to refer after and before patch.
Comment #72
vinaymahale CreditAttribution: vinaymahale as a volunteer and at SJ Innovation LLC commentedReviewed the code from patch #68
Looks good!
Setting to RTBC as per #69
Comment #73
vinaymahale CreditAttribution: vinaymahale as a volunteer and at SJ Innovation LLC commentedComment #74
quietone CreditAttribution: quietone at PreviousNext commentedChanges to the patch where made back in August, #49. Since that time there has not been a review of the patch. I am setting back to needs review for a thorough review of the code. Note that this was tagged for a review in #59 and the tag is still on the issue.
I also see that the patch in #49 was tested in #56 and #62, both adding screenshots. Then rerolled and tested in #69 and #71, again with screenshots. For those who like to test issues, remember to read the comments to ensure that you are adding value to the issue.
Comment #75
DanielVezaAh, just came across this issue - There is two issues for this bug. They should be merged into one. Patches look quite similar. #3307187: Action "Send email" not validating recipient field with multiple addresses
Comment #76
quietone CreditAttribution: quietone at PreviousNext commentedIn #bugsmash, Kristen Pol pointed out that this has a tag of 'Needs review' and was asking about it's relevance. In my last review I should have noticed that and removed the tag because we have the status of 'Needs review'. A tag could be added for a code review but I think it is better to add that this needs a code review to the Issue Summary. I see that was already done (didn't look up when) but there was a spelling mistake which I have fixed.
Comment #77
pameeela CreditAttribution: pameeela at Technocrat commentedThis is definitely a duplicate of #3307187: Action "Send email" not validating recipient field with multiple addresses, the patches are almost identical! This issue is older but the other one has a more recent patch so I am closing this one and will move credit.