Answers.Body: <pre><code>civicrm_api3('MessageTemplate', 'send', array(
    'id' =&gt; 68,
    ... other params - see api explorer ...
  ));
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-08-05T21:39:59.527Z
Answers.Text: Unfortunately api3 explorer does not tell which parameters are required. I tried adding Message Template ID and Contact ID and From email and Receipient email but get an error message back `"error_message": "Could not interpret return values from function."` I then tried removing From email and get this error `"code": null, "error_message": "mail() returned failure", "mode": 16, "debug_info": null, "type": "PEAR_Error", "user_info": null, "to_string": "[pear_error: message=\"mail() returned failure\" code=0 mode=callback callback=CRM_Utils_REST::fatal prefix=\"\" info=\"\"]",`
Answers.UserDisplayName: jsherk
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-08-05T21:45:35.390Z
Answers.Text: Although the api3 explorer was giving error, the actual code worked using the four paramters Message Template ID and Contact ID and From email and Receipient email.
Answers.UserDisplayName: jsherk
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-08-05T17:08:39.173Z
Answers.LastActivityDate: 2022-08-05T17:08:39.173Z
Answers.UserDisplayName: Demerit
Body: <p>How can I send an email using an email template that is already saved (id=68) from within the extension I am working on?</p>
  
Tags: <wordpress><extension><email>
Title: How to send an email using a template from within extension (from code)
ThreadText: # How to send an email using a template from within extension (from code)
  
  (Asked by: username_0 on 2022-08-05)
  
  How can I send an email using an email template that is already saved (id=68) from within the extension I am working on?
  
  **Tags:** wordpress, extension, email
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2022-08-05. Score: 0 | Accepted answer
  
  civicrm_api3('MessageTemplate', 'send', array(
    'id' => 68,
    ... other params - see api explorer ...
  ));
  
  > **Comments:**
  > **username_0**: Unfortunately api3 explorer does not tell which parameters are required. I tried adding Message Template ID and Contact ID and From email and Receipient email but get an error message back `"error_message": "Could not interpret return values from function."` I then tried removing From email and get this error `"code": null, "error_message": "mail() returned failure", "mode": 16, "debug_info": null, "type": "PEAR_Error", "user_info": null, "to_string": "[pear_error: message=\"mail() returned failure\" code=0 mode=callback callback=CRM_Utils_REST::fatal prefix=\"\" info=\"\"]",`  
  > **username_0**: Although the api3 explorer was giving error, the actual code worked using the four paramters Message Template ID and Contact ID and From email and Receipient email.  
  
  ---
  
  