Answers.Body: <p>When you have a delayed email, it generates a record in the <code>civicrm_queue_item</code> table.  Since you're experiencing the same problem without a delay, this is unlikely to solve the problem on its own, but is a good way to troubleshoot whether an email was generated while isolating confounding factors like cron not running, a bad outgoing email setting, etc.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-05-13T21:21:46.287Z
Answers.Text: I did get an error message in the CiviRules log, which I detailed in my edit to the original; question.  Does that help?
Answers.UserDisplayName: David Hyman
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-05-29T12:07:10.440Z
Answers.Text: Yes, location_type_id is empty, which is not valid. Try it with the default location_type_id?
Answers.UserDisplayName: ErikH - CiviCooP
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-05-13T17:02:25.753Z
Answers.LastActivityDate: 2020-05-13T17:02:25.753Z
Answers.UserDisplayName: Jon G - Megaphone Tech
Answers.Body: <p>From your error message it seems that the location_type_id is empty when you try to send the email. That might explain the error as it would expect an integer, and not empty. Could you add a location_type_id in the configuration of the send Email and see if that is a workaround for you?</p>
  
  <p>The action should be able to deal with an empty location_type_id but perhaps the latest version has a little bug there? </p>
  
  <p>If it does work, could you please report the issue here: <a href="https://lab.civicrm.org/extensions/civirules/-/issues" rel="nofollow noreferrer">https://lab.civicrm.org/extensions/civirules/-/issues</a>? That means the developers who want to contribute can see this bug needs to be fixed.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-05-15T00:28:43.443Z
Answers.Text: Good guess.  But, no, Now I get the identical error message, except that it now reads "location_type_id="1"
  Any other suggestions?
Answers.UserDisplayName: David Hyman
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-05-15T18:39:29.327Z
Answers.Text: Not from reading the error message I am afraid....it would require some debugging :-)
Answers.UserDisplayName: ErikH - CiviCooP
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-05-14T06:33:30.073Z
Answers.LastActivityDate: 2020-05-14T06:33:30.073Z
Answers.UserDisplayName: ErikH - CiviCooP
Body: <p>I'm using CiviCRM 5.18.4 on WordPress 5.4.1.  I have been successfully using CiviRules to send a welcome email when a contact adds a (pending) membership.  </p>
  
  <p>Now, I have created a rule that is supposed to send a different ("Membership Confirmation") email when we confirm the person's eligibility and donation:</p>
  
  <p>Linked Trigger:  Membership is changed</p>
  
  <p>Linked Condition(s):  Membership Status is one of   "New"</p>
  
  <p>Linked Action(s):<br>
  Send e-mail from [our email address] using primary e-mailaddress with Template "Membership Confirmation" to the contact and bcc to [internal staff] Delay by 5 minutes  </p>
  
  <p>Have tried it with or without delay, and with various (simplified) email templates.  Result is consistent:  When we approve the donation, it successfully changes the membership status to NEW, and the Event IS TRIGGERED for that contact.  However, the emails do not get sent, and the emails do not appear in the "activities" list for that contact (although the donation and membership activities do).   No error is reported, and nothing at all appears in the CiviRules Log.</p>
  
  <p>[Note:  I just installed the CiviRules Logger extension, I haven't seen any logs appearing even on events that trigger and work properly, so I don't really know if the logger is working.]</p>
  
  <p>Any ideas?  Could something be wrong with the email format?  Is it the way I have written the rule?  Is something going wrong on the back end?  </p>
  
  <p>Thanks for any thoughts!  </p>
  
  <p>UPDATE:  I did finally get an error in the Civirules log:</p>
  
  <p>2020-05-12 18:00    error   Rule: 'Membership Confirmation Email' with id 6 failed for contact 595 because of Failed to execute delayed action<br>
  Array</p>
  
  <p>(
      [rule_title] => Membership Confirmation Email
      [original_error] => Civirules api action exception: id is not a valid integer. API call: Email.send with params: from_name="[org name]", from_email="[our email]", template_id="74", location_type_id="", alternative_receiver_address="", cc="", bcc="[internal staff email]", file_on_case="", contact_id="595", extra_data="Array"</p>
  
  <pre><code>[reason] =&gt; Failed to execute delayed action
  </code></pre>
  
  <p>)</p>
  
  <p>Can anyone interpret that for me?  Which id is not a valid integer?  </p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-05-13T03:10:14.640Z
Comments.Text: isn't there also a civirules email extension needed? do you have that installed?
Comments.UserDisplayName: petednz - fuzion
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-05-13T21:23:49.457Z
Comments.Text: Yes.  I believe it's called  E-mail API (org.civicoop.emailapi).  Version 1.19 installed.
Comments.UserDisplayName: David Hyman
Tags: <civirules><logging>
Title: CiviRules triggers, but fails to send email
ThreadText: # CiviRules triggers, but fails to send email
  
  (Asked by: username_0 on 2020-05-13)
  
  I'm using CiviCRM 5.18.4 on WordPress 5.4.1.  I have been successfully using CiviRules to send a welcome email when a contact adds a (pending) membership.  
  Now, I have created a rule that is supposed to send a different ("Membership Confirmation") email when we confirm the person's eligibility and donation:
  Linked Trigger:  Membership is changed
  Linked Condition(s):  Membership Status is one of   "New"
  Linked Action(s):
  Send e-mail from [our email address] using primary e-mailaddress with Template "Membership Confirmation" to the contact and bcc to [internal staff] Delay by 5 minutes  
  Have tried it with or without delay, and with various (simplified) email templates.  Result is consistent:  When we approve the donation, it successfully changes the membership status to NEW, and the Event IS TRIGGERED for that contact.  However, the emails do not get sent, and the emails do not appear in the "activities" list for that contact (although the donation and membership activities do).   No error is reported, and nothing at all appears in the CiviRules Log.
  [Note:  I just installed the CiviRules Logger extension, I haven't seen any logs appearing even on events that trigger and work properly, so I don't really know if the logger is working.]
  Any ideas?  Could something be wrong with the email format?  Is it the way I have written the rule?  Is something going wrong on the back end?  
  Thanks for any thoughts!  
  UPDATE:  I did finally get an error in the Civirules log:
  2020-05-12 18:00    error   Rule: 'Membership Confirmation Email' with id 6 failed for contact 595 because of Failed to execute delayed action
  Array
  (
      [rule_title] => Membership Confirmation Email
      [original_error] => Civirules api action exception: id is not a valid integer. API call: Email.send with params: from_name="[org name]", from_email="[our email]", template_id="74", location_type_id="", alternative_receiver_address="", cc="", bcc="[internal staff email]", file_on_case="", contact_id="595", extra_data="Array"
  [reason] => Failed to execute delayed action
  
  )
  Can anyone interpret that for me?  Which id is not a valid integer?
  
  **Tags:** civirules, logging
  
  > **Comments:**
  > **username_1**: isn't there also a civirules email extension needed? do you have that installed?  
  > **username_0**: Yes.  I believe it's called  E-mail API (org.civicoop.emailapi).  Version 1.19 installed.  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_2 on 2020-05-13. Score: 0
  
  When you have a delayed email, it generates a record in the `civicrm_queue_item` table. Since you're experiencing the same problem without a delay, this is unlikely to solve the problem on its own, but is a good way to troubleshoot whether an email was generated while isolating confounding factors like cron not running, a bad outgoing email setting, etc.
  
  > **Comments:**
  > **username_0**: I did get an error message in the CiviRules log, which I detailed in my edit to the original; question.  Does that help?  
  > **username_3**: Yes, location_type_id is empty, which is not valid. Try it with the default location_type_id?  
  
  ---
  
  ### Answer by username_3 on 2020-05-14. Score: 0
  
  From your error message it seems that the location\_type\_id is empty when you try to send the email. That might explain the error as it would expect an integer, and not empty. Could you add a location\_type\_id in the configuration of the send Email and see if that is a workaround for you?
  
  The action should be able to deal with an empty location\_type\_id but perhaps the latest version has a little bug there?
  
  If it does work, could you please report the issue here: <https://lab.civicrm.org/extensions/civirules/-/issues>? That means the developers who want to contribute can see this bug needs to be fixed.
  
  > **Comments:**
  > **username_0**: Good guess.  But, no, Now I get the identical error message, except that it now reads "location_type_id="1" Any other suggestions?  
  > **username_3**: Not from reading the error message I am afraid....it would require some debugging :-)  
  
  ---
  
  