CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • post Hook - beginner help?
Pages: [1]

Author Topic: post Hook - beginner help?  (Read 719 times)

lesliejmatthews

  • I’m new here
  • *
  • Posts: 14
  • Karma: 1
  • CiviCRM version: 4.4.6
  • CMS version: drupal 7
  • MySQL version: 5.5.31
  • PHP version: 5.3.1
post Hook - beginner help?
May 26, 2013, 11:50:41 am
Hi

Sorry for such a beginner, vague question but here goes:

I'm trying to set up a post hook to send an email to me whenever a new event participant is added - that's my ultimate goal.  I've started by simply trying to implement the example on the hook specification site: http://wiki.civicrm.org/confluence/display/CRMDOC40/CiviCRM+hook+specification#CiviCRMhookspecification-hook_civicrm_post  (I'm using CiviCRM version 4.1.6 for now).

However, I can't seem to get it to work - I simply don't receive an email.

I think I've done everything obvious:
  - created the appropriate directory and files with the example code copied exactly (except edited to include my real email address)
  - enabled the module on my drupal site

But if I edit or add a new contact no email is received.

Can anyone just really quickly point me in the next direction for troubleshooting this?  It might help to know that I can successfully send emails in all other ways from Civi (i.e. send one email to a contact, send bulk email, and the event registration confirmation emails and profile notification emails also work).

Thanks for your time!

Leslie


Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: post Hook - beginner help?
May 26, 2013, 12:35:22 pm

seems like that sample code might not work, can u do the foll:

a. call the module exampleSendEmail (no spaces or underscores)

b. use this name for the module directory and the .info and .module files

c. use this name as the name of the module in the .info file

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

lesliejmatthews

  • I’m new here
  • *
  • Posts: 14
  • Karma: 1
  • CiviCRM version: 4.4.6
  • CMS version: drupal 7
  • MySQL version: 5.5.31
  • PHP version: 5.3.1
Re: post Hook - beginner help?
May 26, 2013, 01:26:14 pm
Thanks for your help!

I've got it working now, after following your helpful suggestions, renaming everything with no underscores. 

But I also figured out that it only seems to work if the recipient email address is the primary email address for the contact.  In other words - the code sends an email to myself, and I have two email addresses in my contact record in CiviCRM.  The code apparently will send to the primary address but not the secondary address.  Is that a feature of the mail.php function in Utils? Or is that something strange about my secondary email address (which as far as I know works fine).  Or am I imagining things?

Thanks so much for your help!

Leslie

Erik Hommel

  • Forum Godess / God
  • I live on this forum
  • *****
  • Posts: 1773
  • Karma: 59
    • EE-atWork
  • CiviCRM version: all sorts
  • CMS version: Drupal
  • MySQL version: Ubuntu's latest LTS version
  • PHP version: Ubuntu's latest LTS version
Re: post Hook - beginner help?
May 27, 2013, 12:01:55 am
Hi Leslie,

the primary emailaddress is the emailaddress that CiviCRM will use to send emails to. You can certainly send emails to a secondary emailaddress (directly from the contact overview) but all generic 'send a mail' function will use the primary email address. Does that answer your question?

If you want to use all emailaddresses you could change the sample code? Use the API (entity Email action Get) to retrieve all emailaddresses for a contact?
Consultant/project manager at EEatWork and CiviCooP (http://www.civicoop.org/)

lesliejmatthews

  • I’m new here
  • *
  • Posts: 14
  • Karma: 1
  • CiviCRM version: 4.4.6
  • CMS version: drupal 7
  • MySQL version: 5.5.31
  • PHP version: 5.3.1
Re: post Hook - beginner help?
May 27, 2013, 04:01:09 am
Thanks Erik!
« Last Edit: May 27, 2013, 04:11:14 am by lesliejmatthews »

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • post Hook - beginner help?

This forum was archived on 2017-11-26.