How to fix my Rule to notify authors of products by email at order completion? I'm trying to send email notifications to authors of each products (line-items) in the order at completion.

I have tried many things surrounding the rule below... that is now at a strange point in its life.

I can use the [commerce-order:commerce-line-items:0:commerce-product:creator:mail] trick, but that sends the mail only to the first product owner.

{ "rules_commerce_order_message_admin_order_notification" : {
    "LABEL" : "Commerce order message: admin order notification e-mail",
    "PLUGIN" : "reaction rule",
    "WEIGHT" : "3",
    "OWNER" : "rules",
    "REQUIRES" : [ "rules", "message_notify", "commerce_checkout" ],
    "ON" : { "commerce_checkout_complete" : [] },
    "IF" : [
      { "entity_has_field" : { "entity" : [ "commerce-order" ], "field" : "commerce_line_items" } },
      { "entity_has_field" : { "entity" : [ "commerce-order" ], "field" : "commerce_product" } }
    ],
    "DO" : [
      { "entity_create" : {
          "USING" : {
            "type" : "message",
            "param_type" : "commerce_order_admin_order_confirmation",
            "param_user" : [ "commerce-order:owner" ]
          },
          "PROVIDE" : { "entity_created" : { "entity_created" : "Created entity" } }
        }
      },
      { "data_set" : {
          "data" : [ "entity-created:message-commerce-order" ],
          "value" : [ "commerce-order" ]
        }
      },
      { "entity_save" : { "data" : [ "entity-created" ], "immediate" : 1 } },
      { "LOOP" : {
          "USING" : { "list" : [ "commerce-order:commerce-line-items" ] },
          "ITEM" : { "list_item" : "\u00c9l\u00e9ment de la liste courante" },
          "DO" : [
            { "entity_fetch" : {
                "USING" : { "type" : "commerce_product", "id" : [ "list-item:line-item-id" ] },
                "PROVIDE" : { "entity_fetched" : { "entity_product_fetched" : "Entit\u00e9 r\u00e9cup\u00e9r\u00e9e" } }
              }
            },
            { "variable_add" : {
                "USING" : { "type" : "user", "value" : [ "entity-product-fetched:creator" ] },
                "PROVIDE" : { "variable_added" : { "event_creator" : "Variable ajout\u00e9e" } }
              }
            },
            { "message_notify_process" : {
                "message" : [ "entity-created" ],
                "save_on_fail" : "0",
                "save_on_success" : "0",
                "mail" : [ "event-creator:mail" ]
              }
            }
          ]
        }
      }
    ]
  }
}


What's wrong with my rule?

Note:

I would prefer using the Rule, but out of desperation, I have also tried to give directly the email whit something like :

$order = commerce_order_load($order_id);
foreach ($order-&gt;commerce_line_items['und'] as $line) {
$line_item = commerce_line_item_load($line['line_item_id']);
$product_item = commerce_product_load($line_item-&gt;commerce_product['und'][0]['product_id']);
$product_author = user_load($product_item-&gt;uid);
$courriels = $courriels . '&lt;' . $product_author-&gt;mail . '&gt;,';
}
print substr($courriels, 0, strlen($courriels)-1);
Preface
I have the impression that there is indeed &quot;something wrong&quot; in your rule, but please allow me to start with some (constructive intended) critique about the rule you created ...
Your issue may be partially caused because of the naming conventions you used for the variables in your Rules Actions. Your rule processes thingies such as entity_created, list_item and entity_product_created, etc. And you didn't post many details about what this rule is supposed to actually do/achieve. So probably only somebody who knows how to &quot;read&quot; Rules in its export language, may possibly be able to understand your current rule.
Imagine how much easier it would be to READ your rule if you'd have used variables such as admin_order_confirmation_msg, line_item and ordered_product.
What your current rule seems to be doing
By using the kind of variable names I suggested, it seems to me that your last Rules Action is an attempt to send the entire content of the message that you created in your first Rules Action (to be delivered to commerce-order:owner as per that same 1st Rules Action). But in this last Rules Action you ask the Message Notify module to eMail that very same message to what appears to the eMail Id contained in a user object whereas that user object corresponds to the ordered_product in the line_item being processed.
To move on, let's assume you really want the entire order (of X line items) to be eMailed to each (cfr your Rules loop) user that matches a specific ordered_product in any line_item. If that assumption is wrong, then make sure to add another Rules Actionn to create another message (entity) specific to a single line item (which is what I'd do, so that these messages would only contain data about &quot;a&quot; line item, not all of them ...).
Maybe the message module is confused
I've never tried, in a rule, to send the same message &quot;entity&quot; via Message Notify module and also have that same entity delivered (saved) with the Message module. So could it be that you're just confusing the Message module?
And another cause of possible confusion is within the rules module, where sometimes it gets tricky to &quot;save entities&quot;. So possibly adding an appropriate intermediat &quot;save entity&quot; action may also help (if nothing else helps).
Time for some basic Rules debugging
Just (temporary) add a Rules Action to &quot;display a message&quot; (located within group &quot;System&quot;). And show the actual value of your token event-creator:mail as part of that message (btw: this is a Drupal status message, not anything related to the message module).
Based on the actual eMail Ids that will be shown in those debugging messages, you'll know in which direction to move forward to fix your rule.
Maybe add 'Replacement tokens' to your Message entity
If anything above does not help to solve your issue, then it may well be that you can get it to work with the technique of Replacement tokens. For (way) more details on that, head over to the answer to What's the purpose of &quot;Replacement tokens&quot; of a Message type?. I'm pretty sure that using this technique you can create a perfect solution to your issue. If you have more questions about that, use this link.