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) »
  • API to create a new mailing?
Pages: [1]

Author Topic: API to create a new mailing?  (Read 1193 times)

rimu

  • I’m new here
  • *
  • Posts: 14
  • Karma: 0
  • CiviCRM version: 3.4.8
  • CMS version: Drupal 6
API to create a new mailing?
November 02, 2009, 01:59:20 pm
Hi all :)

I need to create a new mailing, in code rather than by using the UI. But there doesn't seem to be an API to achieve this? The documentation has no mention of it and api/v2 has nothing obvious...

I'm trying to achieve something similar to Greenmachine's module http://forum.civicrm.org/index.php/topic,2684.0.html where email is sent to a CiviCRM group. But that module creates and sends the email itself, rather than getting CiviCRM to send it so there is no useful Civi stuff added to the email like tracking and unsubscribe support. Greenmachine's module provides a way for people to unsubscribe through the module, rather than Civi.

If there is no API, can I simply requre('CRM/Mailing/BAO/Mailing.php') and use that class to create a new mailing? There is a create method which looks promising...?

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: API to create a new mailing?
November 02, 2009, 02:12:05 pm

Yes, you will need to include the BAO files and call the classes. In addition you might also want to check the form code in:

CRM/Mailing/Form/* and see what each step does along the way

If you do write a simple wrapper (i dont think it will be very simple), would be great for you to publish the code so future folks can benefit

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

Chris Burgess

  • Ask me questions
  • ****
  • Posts: 675
  • Karma: 59
Re: API to create a new mailing?
December 06, 2012, 01:43:19 pm
This is a three-year-old thread, but Rimu's initial work on creating mails remotely wasn't wasted.

See http://issues.civicrm.org/jira/browse/CRM-11023 for an API method to create CiviMails.
@xurizaemon ● www.fuzion.co.nz

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • API to create a new mailing?

This forum was archived on 2017-11-26.