How to eMail webforms to 2 alternating email adresses? I got a Drupal 7 site with a working webform in it. Now I got 2 email addresses to send the mails to, we want to send them like so:


Send 1st email to emailadress A.
Send 2th email to emailadress B.
Send 3th email to emailadress A again.
Send 4th email to emailadress B again
... and so on.


Can someone help me how to do this or push me in the right direction?

I was thinking about something with the Rules module.
1. Userids with those eMail IDs
Assume that some userid exist for a user named X, with emailadress A, and similarly user Y for emailadress B.
2. Enable the Webform Rules module
Use the Webform Rules module to transform your Webform question to a Rules question. Some details about it (from its project page):

This module adds rules integration on webforms.
Did you ever want to react on webform submission using rules but couldn't find the proper event?
Webform Rules makes it possible to catch webform submissions by rules and do whatever you'd like to do with it (meaning: do whatever rules let you do with it).

To get you going, have a look at this example rule (in Rules export format):
{ &quot;rules_process_submitted_webform&quot; : {
    &quot;LABEL&quot; : &quot;Process submitted webform&quot;,
    &quot;PLUGIN&quot; : &quot;reaction rule&quot;,
    &quot;ACTIVE&quot; : false,
    &quot;OWNER&quot; : &quot;rules&quot;,
    &quot;REQUIRES&quot; : [ &quot;rules&quot;, &quot;webform_rules&quot; ],
    &quot;ON&quot; : { &quot;webform_rules_submit&quot; : [] },
    &quot;DO&quot; : [
      { &quot;mail&quot; : {
          &quot;to&quot; : &quot;[site:mail]&quot;,
          &quot;subject&quot; : &quot;A new webform submission has occurred&quot;,
          &quot;message&quot; : &quot;A new webform submission has occurred (with form-id \u0022[form-id:value]\u0022). It was submitted by the user with id = [user:id], name = [user:name] and eMail Id = [user:mail] ...&quot;,
          &quot;language&quot; : [ &quot;&quot; ]
        }
      }
    ]
  }
}

I intentionally did not include any Rules Conditions here, just to illustrate that by using this Rules Event (= a form is submitted), you do have access to a limited set of tokens related to the user who submitted the webform, such as [user:id], [user:name] and [user:mail].
3. Enable the Flag module
Use the Flag to create a flag for flagging users. Its purpose is to (automatically) indicate which of both users (X or Y) should receive the next eMail, i.e the next eMail should go to the user who is flagged at the time of the webform submission.
4. Create 2 custom rules
a) Send an eMail to user X
Create a 1st custom rule like so:

Rules Event: a form is submitted
Rules Condition: if user X is flagged
Rules Actions:

Send an eMail to user X.
Unflag user X.
Flag user Y.



Note: you probably have to use &quot;switch to direct input mode&quot; multiple times (to be able to enter the uid of user X or Y).
b) Send an eMail to user Y
Create a 2nd custom rule like so:

Rules Event: a form is submitted
Rules Condition: if user Y is flagged
Rules Actions:

Send an eMail to user Y.
Unflag user Y.
Flag user X.



Note: you probably have to use &quot;switch to direct input mode&quot; multiple times (to be able to enter the uid of user X or Y).
5. Perform an initial flagging of a single user
Decide which user (X or Y) should receive the very first eMail, and flag that user. After doing so, next time a webform is submitted the process to send those eMails will start. And as long as you don't flag either one, nothing will happen (as per the implemented Rules logic in step 4 ...).
Note: If you ever want to stop the process, just unflag the user (X or Y) that is flagged.