I am getting an error when using Rules:

Undefined index in rules_action_mail() (line 90 of mywebsite/sites/all/modules/rules/modules/system.eval.inc

The email is getting sent successfully, but this error keeps appearing as well. Any ideas on how to fix this?

#10 rules_mail_lang.patch717 bytesfago
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch rules_mail_lang.patch. Unable to apply patch. See the log in the details link for more information.
[ View ]


I have the same problem.

I'm running Drupal Commerce and on the checkout->completion I get that error and what's worse it makes confirmation page load for more than a minute. I'm not sure if the problem is related to this slow performance but disabling the rule sending the confirmation email makes it work super fast again.

In my case the rule was configured improperly. I probably intalled it without locale module enabled, and then after enablig it the rule required langugage and somehow data selector for it was set to order status.

I can confirm the error. My rule is set to send an email upon creation of a node. When a node is created, I get the error but the email is sent out as expected.

I'm also having this issue.

Event: After saving new content
Condition: Content is sticky
Actions: Unpublish content, Send mail, Show message on site

The email does go through but the page displays the error described above.

I can confirm this error as well. I have created a content type called "Event" that adds events to a site calendar.
When a new Event is created, the rule is supposed to allow the user to add one or more email addresses to send the Event information to.
Here is how my rule is constructed:

Event: after saving new content

Condition: entity has field: Parameter: Entity: [node], Field: field_email_notify
Data comparison: Parameter: Data to compare: [node:field-email-notify], Data value:

Actions: Send mail: Parameter: To: [node:field-email-notify], Subject: You are invited to: "..., Message: You are cordially invited..., From: [site:current-user:mail], Language: [node:type]

Hope this helps!

I guess the Language should be set to node language or manually selected language not the node:type.

I have the same problem. thanks

I'm currently experiencing this issue as well.

Same problem here, anybody have an idea on this or how can i hide the error message until this is solved?

I have the same problem. thanks

Status:Active» Needs review
new717 bytes
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch rules_mail_lang.patch. Unable to apply patch. See the log in the details link for more information.
[ View ]

Does this patch help you?

Status:Needs review» Needs work

The last submitted patch, rules_mail_lang.patch, failed testing.

Status:Needs work» Needs review

Title:Undefined index in rules_action_mail() (line 90Rebuild the mail rules

function rules_action_mail($to, $subject, $message, $from = NULL, $langcode, $settings, RulesState $state, RulesPlugin $element)

is changed from 2.0 to 2.1 - the fifth argument - $langcode is new.

I managed to get rid of the error message at line 90 by opening all my mail-related rules, editing the send mail action and removing the content of the Language field. It had an irrelevant value in it anyway.

I hope this helps.

Thanks a lot, it works for me by removing the content of the Language field.

I deleted and restored my site from an older backup, created the rule using slightly different logic, and the problem went away -- weird. Thanks so much for being out there to help!

I've seen the same problem after updating to 7.23 Dates. module.
I had to revise some rules.
Edit condition: Data compare
before I had node: field-to-start-pub is less than today
now I have to write node: field-to-start-pub: value is less than today
Now everything is OK
Date.module is the problem

Title:Rebuild the mail rulesUndefined index in rules_action_mail()

Please test the patch from #10 so we know whether it fixes the problem without requiring workarounds.

#10 worked for me.

#10 works for me.

Status:Needs review» Reviewed & tested by the community

#10 worked for me as well.

Status:Reviewed & tested by the community» Needs work

I'm not sure if it is related, but I would be surprised if it were not. Since upgrading to Rules 7.x-2.1 our mail actions (executed on Drupal Commerce Checkout Completion) are set to the data selector commerce-order:state. The rules are in their default state, and the data selector is not featurized.

I was having the same problem - removing the language value fixed it for me (was not pertinent anyway).


Agreed, saving the send mail action after removing the content from Language and re-featurizing solves the problem. Is this related to the current issu, if so should it be rolled into the same patch?

Here is the quick fix that worked for me:

* Action Implementation: Send mail.
function rules_action_mail($to, $subject, $message, $from = NULL, $langcode, $settings, RulesState $state, RulesPlugin $element) {
$to = str_replace(array("\r", "\n"), '', $to);
$from = !empty($from) ? str_replace(array("\r", "\n"), '', $from) : NULL;
$params = array(
'subject' => $subject,
'message' => $message,
'langcode' => $langcode,
// Set a unique key for this mail.
$name = isset($element->root()->name) ? $element->root()->name : 'unnamed';
$key = 'rules_action_mail_' . $name . '_' . $element->elementId();
$languages = language_list();

  $current_lang_dflt = language_default();
  $langcode = $current_lang_dflt->prefix;

$language = $langcode == LANGUAGE_NONE ? language_default() : $languages[$langcode];

$message = drupal_mail('rules', $key, $to, $language, $params, $from);
if ($message['result']) {
watchdog('rules', 'Successfully sent email to %recipient', array('%recipient' => $to));

I think your code should be like this:

  $current_lang_dflt = language_default();
  $langcode = $current_lang_dflt->language;

when I try to add text in non english on the "Send an order notification e-mail" - drupal commerce, - I get the same error!
There is a solution for that?
whats wrong?

Status:Needs work» Needs review

#10: rules_mail_lang.patch queued for re-testing.

Status:Needs review» Needs work

The last submitted patch, rules_mail_lang.patch, failed testing.

Hi all,
can I use the patch, rules_mail_lang.patch?
does this patch will solve the bug?
why the patch, rules_mail_lang.patch failed testing?

Title:Undefined index in rules_action_mail()Send mail action assumes i18n is in use and prodcues a non-fatal error
Version:7.x-2.1» 7.x-2.x-dev
Component:Rules Engine» Rules Core
Assigned:Unassigned» klausi
Status:Needs work» Reviewed & tested by the community

(14, 18, 19) confirm the fix in #10.

(21, 23-30) aren't related to the patch.

@21: Please open a separate issue and explain the context further.

#10: rules_mail_lang.patch queued for re-testing.

Is there anyway I can get around this until the update is officially available?

Thanks guys for the help!

Status:Reviewed & tested by the community» Fixed

Committed #10 , thanks.

Status:Fixed» Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.