Hello. I am using the rules module to send an email to the email address entered by a user. This email is sent to the entered email address every time a node is created, of a certain type. I needed a field with multiple email entry possibility but have not been able to find a way to send mail to all of the entered emails. I believe this is because there is only one CCK token for each field.
So now I am thinking about having the user enter multiple emails (if required) in a single text field, separated by a delimiter (instructions in my help text for the field). Is there some type of delimiter the rules module allows (i've tried comma and semi-colon)? And would i use the raw or formatted token with this type of email entry?
Any tips?
Thanks!
MT
Comments
Comment #1
danzsmith commented+1 - we are fighting the exact same issue and could use any guidance available on this...thank you!
Comment #2
danzsmith commentedAnybody have any ideas on this? Thanks!
Comment #3
milant commentedEven the smallest solution/idea would help.
MT
Comment #4
dillonm commentedAre you using an email widget for you CCK field? I see "Send email to the value of an email widget field" in my rule actions for content being saved. I was under the impression that this would work. In the CCK options for the field, just make sure to allow multiple fields.
Comment #5
milant commentedi was at the time using simple text fields. And with the field you are describing, if you allow multiple entries, how would you use that field's token to input each of these addresses into a "recipient" field (without php)?
What I did was change my filed to use a user reference (with realname integrated). Then i used this piece of php code in my "recipient" field to send the emails to whatever number of users entered (no limit) into the user reference fields.
foreach ($node->field_my_users_referenced as $r) {$u = user_load($r['uid']); $m[] = $u->mail;} echo implode(',', $m);Worked out for me and it was actually better than what i was trying to do initially.
Thanks for your input though. If i ever have to do the same without using a user reference, i will be sure to give that method a try.
MT
Comment #6
rimu commentedIf you want to send to multiple email addresses, you need to format them like this:
<email1@whatever.com>,<email2@whatever.com>,<email3@whatever.com>NB the angle brackets and the commas with no spaces.
Comment #7
devad commentedThank you @rimu.
It works for me for drupal 7 as well.
Comment #8
crutch commentedD7, But what if you have a single email field that allows multiple addresses and the token is
[node:field-visit-coord-add-emails]
and that token contains say 5 email addresses. Should it be formatted in the rule To: value like this?
[node:field-visit-coord-add-emails:0],[node:field-visit-coord-add-emails:1],[node:field-visit-coord-add-emails:2],[node:field-visit-coord-add-emails:3],[node:field-visit-coord-add-emails:4]this does not work---
this does not work.Additionally, when an email field has unlimited "Add another item" option, then will that work just using the token [node:field-visit-coord-add-emails]?
Ended up creating 5 unique email fields and formatted the cc field in the action with these tokens and format.
<[node:field-visit-add-recipient-1]>,<[node:field-visit-add-recipient-2]>,<[node:field-visit-add-recipient-3]>,<[node:field-visit-add-recipient-4]>,<[node:field-visit-add-recipient-5]>
Successfully sends mails but I think the issue with this method is those fields are optional. If less than 5 email recipients are added then there is a mail send error in the logs for the fields not used.
Comment #9
tr commentedDrupal 6 has been unsupported for almost three years now, and Rules and the Rules UI is substantially different in D7 and D8. I don't think this is an issue any longer, but if it is still a problem with the current version of Rules please open a new issue.