Answers.Body: <p>to be checked, but creating a mailing should go through the normal hooks like the other entities in civi</p>
  
  <p>so if you go with the pre or post hooks
  <a href="http://wiki.civicrm.org/confluence/display/CRMDOC/Database+hooks" rel="nofollow">http://wiki.civicrm.org/confluence/display/CRMDOC/Database+hooks</a></p>
  
  <pre><code>hook_civicrm_post( $op, $objectName, $objectId, &amp;$objectRef )   
  </code></pre>
  
  <p>you should have one with the objectname mailing you want to handle and do the needed</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-07-01T23:31:35.797Z
Answers.Text: Aha, generic hooks! I'll give it a try and report back.
Answers.UserDisplayName: Effy Elden
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-07-01T08:51:48.507Z
Answers.LastActivityDate: 2015-07-01T08:51:48.507Z
Answers.UserDisplayName: Xavier
Body: <p>I want to call a function whenever a CiviMail is sent from our system, to send a log message to a third party system (Slack in this case).</p>
  
  <p>I've had a look at the CiviCRM documentation, and while I can see hooks for both before/after an <em>email</em> is sent, I can't see one for a CiviMailing. I could in theory use these hooks, but even if I de-duplicated it down to a single record, it wouldn't contain information about the mailing (such as mailing name, mailing size, groups, etc).</p>
  
  <p>What's the best option to accomplish this? Is there a relevant hook? Would I need to run a cronjob to check the relevant tables?</p>
  
Tags: <civimail><email><hooks><logs>
Title: Is there a hook for when a CiviMail is created/scheduled/sent/completed?
ThreadText: # Is there a hook for when a CiviMail is created/scheduled/sent/completed?
  
  (Asked by: username_0 on 2015-07-01)
  
  I want to call a function whenever a CiviMail is sent from our system, to send a log message to a third party system (Slack in this case).
  
  I've had a look at the CiviCRM documentation, and while I can see hooks for both before/after an *email* is sent, I can't see one for a CiviMailing. I could in theory use these hooks, but even if I de-duplicated it down to a single record, it wouldn't contain information about the mailing (such as mailing name, mailing size, groups, etc).
  
  What's the best option to accomplish this? Is there a relevant hook? Would I need to run a cronjob to check the relevant tables?
  
  **Tags:** civimail, email, hooks, logs
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2015-07-01. Score: 1
  
  to be checked, but creating a mailing should go through the normal hooks like the other entities in civi
  so if you go with the pre or post hooks
  http://wiki.civicrm.org/confluence/display/CRMDOC/Database+hooks
  hook_civicrm_post( $op, $objectName, $objectId, &$objectRef )   
  
  you should have one with the objectname mailing you want to handle and do the needed
  
  > **Comments:**
  > **username_0**: Aha, generic hooks! I'll give it a try and report back.  
  
  ---
  
  