Answers.Body: <p>Take a look at CRM_Activity_BAO_Activity::sendEmail(). An example of its use at <a href="https://github.com/civicrm/civicrm-core/blob/236007df15c5e3c65866b9cdd53fcd7593bb82c8/CRM/Contact/Form/Task/EmailTrait.php#L416" rel="nofollow noreferrer">https://github.com/civicrm/civicrm-core/blob/236007df15c5e3c65866b9cdd53fcd7593bb82c8/CRM/Contact/Form/Task/EmailTrait.php#L416</a></p>
  <p>Note that it's not an &quot;official&quot; api and may change in the future, but that's also true of CRM_Utils_Mail.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-06-11T20:15:05.080Z
Answers.LastActivityDate: 2021-06-11T20:15:05.080Z
Answers.UserDisplayName: Demerit
Body: <p>I have a custom extension which I have working great- sends out email using the CRM_Utils_mail function.  The emails go out fine, look fine, but are not registered to the contact's profile (not under the Mailings tab, or any of the others).</p>
  <pre><code>$emailbody = (CRM_Core_Smarty::singleton()-&gt;fetch($turl));
          $params = array();
          $params['from'] = 'Sporting Detection Dogs Association &lt;no@x-x-x.ca&gt;';
          $params['toName'] = $values['Requester_Name'].' '.$values['Requester_lastname'];
          $params['toEmail'] = $contact['email'];
          $params['subject'] = 'Trial Approval';
          $params['text'] = '';
          $params['html'] = $emailbody;
          CRM_Utils_Mail::send($params);
  </code></pre>
  <p>Is there a parameter I can add to make it add to the history for the record?  Also, as a sidenote, how do I add more than one toEmail address?</p>
  <p>thanks in advance.</p>
  
Tags: <extension><email><developer>
Title: Using CRM_Utils_Mail and logs
ThreadText: # Using CRM_Utils_Mail and logs
  
  (Asked by: username_0 on 2021-06-11)
  
  I have a custom extension which I have working great- sends out email using the CRM_Utils_mail function.  The emails go out fine, look fine, but are not registered to the contact's profile (not under the Mailings tab, or any of the others).
  $emailbody = (CRM_Core_Smarty::singleton()->fetch($turl));
          $params = array();
          $params['from'] = 'Sporting Detection Dogs Association ';
          $params['toName'] = $values['Requester_Name'].' '.$values['Requester_lastname'];
          $params['toEmail'] = $contact['email'];
          $params['subject'] = 'Trial Approval';
          $params['text'] = '';
          $params['html'] = $emailbody;
          CRM_Utils_Mail::send($params);
  
  Is there a parameter I can add to make it add to the history for the record?  Also, as a sidenote, how do I add more than one toEmail address?
  thanks in advance.
  
  **Tags:** extension, email, developer
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2021-06-11. Score: 1
  
  Take a look at CRM\_Activity\_BAO\_Activity::sendEmail(). An example of its use at <https://github.com/civicrm/civicrm-core/blob/236007df15c5e3c65866b9cdd53fcd7593bb82c8/CRM/Contact/Form/Task/EmailTrait.php#L416>
  
  Note that it's not an "official" api and may change in the future, but that's also true of CRM\_Utils\_Mail.
  
  
  ---
  
  