If have a rule that sends a mail to an arbitrary email address. The mail was being sent successfully until I inserted the following code:

if ( $node->field_authorizer[0][value] == 'Mr. John Mason') {
  echo 'jmason@lomira.k12.wi.us' ; 
} 
elseif ( $node->field_authorizer[0][value] == 'Mr. Bob Lloyd') {
  print 'blloyd@lomira.k12.wi.us';  
} 
elseif ( $node->field_authorizer[0][value] == 'Mrs. Lori Loehr') {
  print 'lloehr@lomira.k12.wi.us';  
} 
elseif ( $node->field_authorizer[0][value] == 'Mrs. Shannon Stein') {
  print 'sstein@lomira.k12.wi.us';  
} 
else {
print 'That thing didn't work at all.'; 
}

Now it says: Unable to send e-mail. Please contact the site administrator if the problem persists.

I'm fairly certain that is the correct syntax. I even tried adding "global $user;" (shouldn't be necessary) but still no dice.

I'm guessing Rules simply doesn't support that sort of PHP? Or my PHP is wrong?

Comments

ballerjones’s picture

Component: Rules Core » Rules Engine

By the way, I did fix that apostrophe error:

else {
print 'That thing didn't work at all.;
}

to:

else {
print 'That thing didnt work at all.';
}

But still get the same error.

fago’s picture

Category: bug » support
Status: Active » Fixed
ballerjones’s picture

Status: Fixed » Active

Read my last sentence:

"But still get the same error."

Unable to send e-mail. Please contact the site administrator if the problem persists
mitchell’s picture

For a related feature request, see #326808: Support logic-based dialects (if/then/else).

mitchell’s picture

Status: Active » Closed (fixed)

Closing older issues to make the issue queue easier to navigate. If you still need assistance, please try the latest versions, read through the documentation handbooks, and search for other other issues with relevant responses. This will more than likely give you an answer to your question, or you can always open another issue. If you have any further help to offer people who may find this issue, please add it even though it is closed or add this info to the documentation handbook. Thank you.