3 * Test Generated example demonstrating the Mailing.create API.
8 function mailing_create_example() {
10 'subject' => 'Hello {contact.display_name}',
11 'body_text' => 'This is {contact.display_name}.
12 {domain.address}{action.optOutUrl}',
13 'body_html' => '<p>This is {contact.display_name}.</p><p>{domain.address}{action.optOutUrl}</p>',
14 'name' => 'mailing name',
31 'force_rollback' => 1,
33 'api.mailing_job.create' => 1,
34 'api.MailingRecipients.get' => array(
35 'mailing_id' => '$value.id',
36 'api.contact.getvalue' => array(
37 'return' => 'display_name',
39 'api.email.getvalue' => array(
46 $result = civicrm_api3('Mailing', 'create', $params);
48 catch (CiviCRM_API3_Exception
$e) {
50 $errorMessage = $e->getMessage();
51 $errorCode = $e->getErrorCode();
52 $errorData = $e->getExtraParams();
54 'error' => $errorMessage,
55 'error_code' => $errorCode,
56 'error_data' => $errorData,
64 * Function returns array of result expected from previous function.
69 function mailing_create_expectedresult() {
71 $expectedResult = array(
83 'unsubscribe_id' => '5',
84 'resubscribe_id' => '6',
86 'name' => 'mailing name',
87 'from_name' => 'FIXME',
88 'from_email' => 'info@EXAMPLE.ORG',
89 'replyto_email' => 'info@EXAMPLE.ORG',
90 'subject' => 'Hello {contact.display_name}',
91 'body_text' => 'This is {contact.display_name}.
92 {domain.address}{action.optOutUrl}',
93 'body_html' => '<p>This is {contact.display_name}.</p><p>{domain.address}{action.optOutUrl}</p>',
94 'url_tracking' => '1',
95 'forward_replies' => '',
96 'auto_responder' => '',
97 'open_tracking' => '1',
99 'msg_template_id' => '',
100 'override_verp' => '1',
102 'created_date' => '2013-07-28 08:49:19',
103 'scheduled_id' => '',
104 'scheduled_date' => '',
106 'approval_date' => '',
107 'approval_status_id' => '',
108 'approval_note' => '',
110 'visibility' => 'Public Pages',
112 'dedupe_email' => '1',
113 'sms_provider_id' => '',
115 'location_type_id' => '',
116 'email_selection_method' => '',
117 'api.mailing_job.create' => array(
126 'scheduled_date' => '20130728085413',
129 'status' => 'Scheduled',
138 'api.MailingRecipients.get' => array(
147 'contact_id' => '10',
149 'api.contact.getvalue' => 'Mr. Includer Person II',
150 'api.email.getvalue' => 'include.me@example.org',
158 return $expectedResult;
162 * This example has been generated from the API test suite.
163 * The test that created it is called "testMailerPreviewRecipients"
164 * and can be found at:
165 * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/MailingTest.php
167 * You can see the outcome of the API tests at
168 * https://test.civicrm.org/job/CiviCRM-master-git/
170 * To Learn about the API read
171 * http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
173 * Browse the api on your own site with the api explorer
174 * http://MYSITE.ORG/path/to/civicrm/api
176 * Read more about testing here
177 * http://wiki.civicrm.org/confluence/display/CRM/Testing
179 * API Standards documentation:
180 * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards