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}.
13 {domain.address}{action.optOutUrl}',
14 'body_html' => '<link href=\'https://fonts.googleapis.com/css?family=Roboto+Condensed:400,700|Zilla+Slab:500,700\' rel=\'stylesheet\' type=\'text/css\'><p><a href=\"http://{action.forward}\">Forward this email</a><a href=\"{action.forward}\">Forward this email with no protocol</a></p<p>This is {contact.display_name}.</p><p><a href=\'https://civicrm.org/\'>CiviCRM.org</a></p><p>{domain.address}{action.optOutUrl}</p>',
15 'name' => 'mailing name',
32 'force_rollback' => 1,
34 'api.MailingRecipients.get' => [
35 'mailing_id' => '$value.id',
36 'api.contact.getvalue' => [
37 'return' => 'display_name',
39 'api.email.getvalue' => [
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();
55 'error_message' => $errorMessage,
56 'error_code' => $errorCode,
57 'error_data' => $errorData,
65 * Function returns array of result expected from previous function.
70 function mailing_create_expectedresult() {
84 'unsubscribe_id' => '5',
85 'resubscribe_id' => '6',
87 'name' => 'mailing name',
88 'mailing_type' => 'standalone',
89 'from_name' => 'FIXME',
90 'from_email' => 'info@EXAMPLE.ORG',
91 'replyto_email' => 'info@EXAMPLE.ORG',
92 'template_type' => 'traditional',
93 'template_options' => '',
94 'subject' => 'Hello {contact.display_name}',
95 'body_text' => 'This is {contact.display_name}.
97 {domain.address}{action.optOutUrl}',
98 'body_html' => '<link href=\'https://fonts.googleapis.com/css?family=Roboto+Condensed:400,700|Zilla+Slab:500,700\' rel=\'stylesheet\' type=\'text/css\'><p><a href=\"http://{action.forward}\">Forward this email</a><a href=\"{action.forward}\">Forward this email with no protocol</a></p<p>This is {contact.display_name}.</p><p><a href=\'https://civicrm.org/\'>CiviCRM.org</a></p><p>{domain.address}{action.optOutUrl}</p>',
99 'url_tracking' => '1',
100 'forward_replies' => 0,
101 'auto_responder' => 0,
102 'open_tracking' => '1',
103 'is_completed' => '',
104 'msg_template_id' => '',
105 'override_verp' => '1',
106 'created_id' => '15',
107 'created_date' => '2013-07-28 08:49:19',
108 'modified_date' => '2012-11-14 16:02:35',
109 'scheduled_id' => '',
110 'scheduled_date' => '',
112 'approval_date' => '',
113 'approval_status_id' => '',
114 'approval_note' => '',
116 'visibility' => 'Public Pages',
118 'dedupe_email' => '1',
119 'sms_provider_id' => '',
121 'location_type_id' => '',
122 'email_selection_method' => 'automatic',
124 'api.MailingRecipients.get' => [
133 'contact_id' => '16',
135 'api.contact.getvalue' => 'Mr. Includer Person II',
136 'api.email.getvalue' => 'include.me@example.org',
144 return $expectedResult;
148 * This example has been generated from the API test suite.
149 * The test that created it is called "testMailerPreviewRecipients"
150 * and can be found at:
151 * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/MailingTest.php
153 * You can see the outcome of the API tests at
154 * https://test.civicrm.org/job/CiviCRM-Core-Matrix/
156 * To Learn about the API read
157 * https://docs.civicrm.org/dev/en/latest/api/
159 * Browse the API on your own site with the API Explorer. It is in the main
160 * CiviCRM menu, under: Support > Development > API Explorer.
162 * Read more about testing here
163 * https://docs.civicrm.org/dev/en/latest/testing/
165 * API Standards documentation:
166 * https://docs.civicrm.org/dev/en/latest/framework/api-architecture/