Problem/Motivation
Using Drupal 7.
Want to create an advanced action in configuration:actions to Send Email.
When I do that, in the Recipient Field I want to add a tokenized field from the list below. It's a field I created with the "Email Field" module. It inserts the tokenized field when I click on it. The tokenized field is called [node:field-email].
When I submit the page however, it gives error: "Enter a valid email address or use a token e-mail address such as [node:author:mail]." But I am using a token email address, one that is created with the email field module.
Why doesn't it like my email field token?
I'm otherwise stuck with this because if I try to use Rules instead, there are bugs with Rules 7 to the point that I can't send an email that way either because I get fatal errors.
Steps to reproduce
Proposed resolution
Remaining tasks
Reroll patch
Write a test
Review
Commit
User interface changes
API changes
Data model changes
Release notes snippet
| Comment | File | Size | Author |
|---|---|---|---|
| #13 | 1066060-13-token_email_fix.patch | 936 bytes | wiifm |
| #7 | 1066060-now-with-git.patch | 916 bytes | wiifm |
| #3 | token-email-1066060.patch | 852 bytes | wiifm |
Comments
Comment #1
jeremyll commentedsubscribing
Comment #2
dave reidThat validation is performed by core's system module, not Token. And this is *definitely* not a critical issue. Please read http://drupal.org/node/45111 for more information on issue priorities.
Comment #3
wiifmHaving the same issue here, we created custom tokens, and the form was refusing to save
Found the offending code on line 3127 of system.module:
So it appears, as our custom token does not have the string ':mail' in it, it is being rejected.
Surely a better solution would be to check for either:
a) valid email address
b) valid token
And leave it up to the token creator to ensure the token conforms to the correct syntax for having email address(es)?
Attached is a patch, that proposes solution b) (patch created from SVN on drupal 7.9 - sorry!)
Anyone core maintainers want to add anything here?
Sean
Comment #4
wiifmsetting tags for review
Comment #6
lk7889 commentedThe patch failed but if I manually update the system.module with the code in the patch, it works like a charm for me.
Comment #7
wiifmNew patch made from git, this should apply
Comment #8
wiifmComment #9
irunflower commentedTested patch in #7 with Drupal 7.14:
patching file modules/system/system.module
patch unexpectedly ends in middle of line
Hunk #1 succeeded at 3156 with fuzz 1 (offset 30 lines)
But patch worked, problem solved.
Comment #10
wiifm@irunflower - if the patch does not work, can you roll another one?
Also if you like the patch, please consider marking it 'Reviewed and Tested by the Community', rather than closing it ;)
Comment #11
irunflower commentedComment #12
David_Rothstein commentedLooks like this code still exists in Drupal 8, so presumably the bug exists there too. So we need to fix this in Drupal 8 first.
Comment #13
wiifm8.x patch rolled
Comment #16
mgiffordWhat happened to function system_send_email_action_validate()? I can't grep it.
Comment #17
Collins405 commentedWorks beautifully, how do we implement this without hacking core?
Comment #18
mgifford@Collins405 you are using D7, right?
This has to be fixed first in D8, then it can be backported to D7. That is unless this problem no longer exists in D8.
Comment #28
quietone commentedFrom reading the code this problem still exists.
The validation is now in \Drupal\Core\Action\Plugin\Action\EmailAction::validateConfigurationForm and that is where the change suggested in the patch needs to move to. Changing component to Action module. This will also need a test. I've started an update of the IS but it is not complete. Adding tags. And removing unnecessary tags.
Comment #31
imclean commentedThere is another problem with
EmailAction->validateConfigurationForm(). The recipient field can contain a comma separated list of email addresses, however the email validator used doesn't take that into account.One solution would be to split on a comma and loop through the addresses, validating each one. But if egulias/EmailValidator supports validating against an email list that might be a better to use that properly.
https://api.drupal.org/api/drupal/vendor%21egulias%21email-validator%21s...
Comment #32
imclean commentedRe #31: #3307187: Action "Send email" not validating recipient field with multiple addresses
Comment #34
quietone commentedAction module is approved for removal. See #3266458: [Policy] Deprecate Action (UI) module in D10 and move to contrib in D11
This is now Postponed. The status is set according to two policies. The Remove a core extension and move it to a contributed project and the Extensions approved for removal policies.
It will be moved to the contributed Action project when the Drupal 11 branch is open.
Comment #36
andypostthe module moved to contrib project but not actions