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 (Moderator: Donald Lobo) »
  • Sending emails through CiviMail programmatically?
Pages: [1]

Author Topic: Sending emails through CiviMail programmatically?  (Read 1107 times)

willmoy

  • Guest
Sending emails through CiviMail programmatically?
May 13, 2010, 07:35:44 am
Hello

Could anyone give me a starting point for trying to trigger a CiviMail job through code? I expected the code base to be more drupalish, and now looking at it I realise I haven't a clue where to start.

What I want to be able to do is expose a drupal action for sending something with arguments for subject, body and recipients.

Thanks

Will

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: Sending emails through CiviMail programmatically?
May 13, 2010, 08:11:20 am
You mean bypassing the wizard completely ?

There isn't an api yet to store a mailing, but create one that wraps around CRM_Mailing_BAO_Mailing shouldn't be that complicated, and the best way IMO to be able to do what you want.

In general on the api, you'd want to have at least a create, update, get and delete method, and you might get requested to write some unit tests (nothing that complicated, and helps to be sure it works the way you want).

If you are up to the task, you might want to write down on the wiki what params it takes (quite a few between the groups you want to includes/exclude, the header/footer, subject/body and so on, and post so we can help be sure it will work.


X+
-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

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: Sending emails through CiviMail programmatically?
May 13, 2010, 01:10:39 pm

also the mailing is sent via:

CRM/Mailing/BAO/Job.php, function runJobs

if you want to wrap that up also

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

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: Sending emails through CiviMail programmatically?
May 13, 2010, 02:18:01 pm
Quote from: willmoy on May 13, 2010, 07:35:44 am
I expected the code base to be more drupalish, and now looking at it I realise I haven't a clue where to start.

Curious as to why u expected the code to be more drupal-ish. Any specific things u read on wiki/blog/forum to give u that impression? I suspect it will help folks, if we let them know that civicrm code is not drupal-ish.

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

willmoy

  • Guest
Re: Sending emails through CiviMail programmatically?
June 07, 2010, 01:46:31 pm
Apologies. I thought I was signed up for email notification of replies and hadn't seen all your help.

Lobo: I don't think there was any good reason for me to think the code would be drupalish, just an assumption because I come from a drupal background and tend to associate the two projects. Certainly can't point to any misleading information on the site. As your series on CiviCRM's architecture comes through, I think that will be immensely helpful to new developers. For example, finding this page on forms was helpful to me: http://civicrm.org/node/98

I am having a go at this, and in the cause of figuring out the codebase I have just set up an api.drupal.org style site for CiviCRM, which you can find at http://civiapi.idealworld.org/api/civicrm/3.1.5. Dunno if that's something you might find helpful.

Cheers

Will

Piyush

  • I’m new here
  • *
  • Posts: 14
  • Karma: 0
    • Pecan Solutions
Re: Sending emails through CiviMail programmatically?
June 21, 2010, 07:18:05 am
Hi Will,

Just seen this post and your http://civiapi.idealworld.org/api/civicrm/3.1.5.

What you've done is really useful - thanks! I tried to do something similar recently using the Drupal API module but it didn't work as well as your implementation.

Can you share how you did this - which Drupal modules did you need and did you make any changes to them or the grammar parser, etc? I would like to set this up on a local development install.

This would also be great to implement on the civicrm.org main site as an API reference.

- Piyush

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • Sending emails through CiviMail programmatically?

This forum was archived on 2017-11-26.