Overview

Namespaces

  • None
  • PHP

Classes

  • Mandrill
  • Mandrill_Exports
  • Mandrill_Inbound
  • Mandrill_Internal
  • Mandrill_Ips
  • Mandrill_Messages
  • Mandrill_Rejects
  • Mandrill_Senders
  • Mandrill_Subaccounts
  • Mandrill_Tags
  • Mandrill_Templates
  • Mandrill_Urls
  • Mandrill_Users
  • Mandrill_Webhooks
  • Mandrill_Whitelists

Exceptions

  • Mandrill_Error
  • Mandrill_HttpError
  • Mandrill_Invalid_DeleteDefaultPool
  • Mandrill_Invalid_DeleteNonEmptyPool
  • Mandrill_Invalid_EmptyDefaultPool
  • Mandrill_Invalid_Key
  • Mandrill_Invalid_Reject
  • Mandrill_Invalid_Tag_Name
  • Mandrill_Invalid_Template
  • Mandrill_IP_ProvisionLimit
  • Mandrill_PaymentRequired
  • Mandrill_ServiceUnavailable
  • Mandrill_Unknown_Export
  • Mandrill_Unknown_InboundDomain
  • Mandrill_Unknown_IP
  • Mandrill_Unknown_Message
  • Mandrill_Unknown_Pool
  • Mandrill_Unknown_Sender
  • Mandrill_Unknown_Subaccount
  • Mandrill_Unknown_Template
  • Mandrill_Unknown_Url
  • Mandrill_Unknown_Webhook
  • Mandrill_ValidationError
  • Overview
  • Namespace
  • Class
  • Tree
  1: <?php
  2: 
  3: class Mandrill_Templates {
  4:     public function __construct(Mandrill $master) {
  5:         $this->master = $master;
  6:     }
  7: 
  8:     /**
  9:      * Add a new template
 10:      * @param string $name the name for the new template - must be unique
 11:      * @param string $from_email a default sending address for emails sent using this template
 12:      * @param string $from_name a default from name to be used
 13:      * @param string $subject a default subject line to be used
 14:      * @param string $code the HTML code for the template with mc:edit attributes for the editable elements
 15:      * @param string $text a default text part to be used when sending with this template
 16:      * @param boolean $publish set to false to add a draft template without publishing
 17:      * @return struct the information saved about the new template
 18:      *     - slug string the immutable unique code name of the template
 19:      *     - name string the name of the template
 20:      *     - code string the full HTML code of the template, with mc:edit attributes marking the editable elements - draft version
 21:      *     - subject string the subject line of the template, if provided - draft version
 22:      *     - from_email string the default sender address for the template, if provided - draft version
 23:      *     - from_name string the default sender from name for the template, if provided - draft version
 24:      *     - text string the default text part of messages sent with the template, if provided - draft version
 25:      *     - publish_name string the same as the template name - kept as a separate field for backwards compatibility
 26:      *     - publish_code string the full HTML code of the template, with mc:edit attributes marking the editable elements that are available as published, if it has been published
 27:      *     - publish_subject string the subject line of the template, if provided
 28:      *     - publish_from_email string the default sender address for the template, if provided
 29:      *     - publish_from_name string the default sender from name for the template, if provided
 30:      *     - publish_text string the default text part of messages sent with the template, if provided
 31:      *     - published_at string the date and time the template was last published as a UTC string in YYYY-MM-DD HH:MM:SS format, or null if it has not been published
 32:      *     - created_at string the date and time the template was first created as a UTC string in YYYY-MM-DD HH:MM:SS format
 33:      *     - updated_at string the date and time the template was last modified as a UTC string in YYYY-MM-DD HH:MM:SS format
 34:      */
 35:     public function add($name, $from_email=null, $from_name=null, $subject=null, $code=null, $text=null, $publish=true) {
 36:         $_params = array("name" => $name, "from_email" => $from_email, "from_name" => $from_name, "subject" => $subject, "code" => $code, "text" => $text, "publish" => $publish);
 37:         return $this->master->call('templates/add', $_params);
 38:     }
 39: 
 40:     /**
 41:      * Get the information for an existing template
 42:      * @param string $name the immutable name of an existing template
 43:      * @return struct the requested template information
 44:      *     - slug string the immutable unique code name of the template
 45:      *     - name string the name of the template
 46:      *     - code string the full HTML code of the template, with mc:edit attributes marking the editable elements - draft version
 47:      *     - subject string the subject line of the template, if provided - draft version
 48:      *     - from_email string the default sender address for the template, if provided - draft version
 49:      *     - from_name string the default sender from name for the template, if provided - draft version
 50:      *     - text string the default text part of messages sent with the template, if provided - draft version
 51:      *     - publish_name string the same as the template name - kept as a separate field for backwards compatibility
 52:      *     - publish_code string the full HTML code of the template, with mc:edit attributes marking the editable elements that are available as published, if it has been published
 53:      *     - publish_subject string the subject line of the template, if provided
 54:      *     - publish_from_email string the default sender address for the template, if provided
 55:      *     - publish_from_name string the default sender from name for the template, if provided
 56:      *     - publish_text string the default text part of messages sent with the template, if provided
 57:      *     - published_at string the date and time the template was last published as a UTC string in YYYY-MM-DD HH:MM:SS format, or null if it has not been published
 58:      *     - created_at string the date and time the template was first created as a UTC string in YYYY-MM-DD HH:MM:SS format
 59:      *     - updated_at string the date and time the template was last modified as a UTC string in YYYY-MM-DD HH:MM:SS format
 60:      */
 61:     public function info($name) {
 62:         $_params = array("name" => $name);
 63:         return $this->master->call('templates/info', $_params);
 64:     }
 65: 
 66:     /**
 67:      * Update the code for an existing template. If null is provided for any fields, the values will remain unchanged.
 68:      * @param string $name the immutable name of an existing template
 69:      * @param string $from_email the new default sending address
 70:      * @param string $from_name the new default from name
 71:      * @param string $subject the new default subject line
 72:      * @param string $code the new code for the template
 73:      * @param string $text the new default text part to be used
 74:      * @param boolean $publish set to false to update the draft version of the template without publishing
 75:      * @return struct the template that was updated
 76:      *     - slug string the immutable unique code name of the template
 77:      *     - name string the name of the template
 78:      *     - code string the full HTML code of the template, with mc:edit attributes marking the editable elements - draft version
 79:      *     - subject string the subject line of the template, if provided - draft version
 80:      *     - from_email string the default sender address for the template, if provided - draft version
 81:      *     - from_name string the default sender from name for the template, if provided - draft version
 82:      *     - text string the default text part of messages sent with the template, if provided - draft version
 83:      *     - publish_name string the same as the template name - kept as a separate field for backwards compatibility
 84:      *     - publish_code string the full HTML code of the template, with mc:edit attributes marking the editable elements that are available as published, if it has been published
 85:      *     - publish_subject string the subject line of the template, if provided
 86:      *     - publish_from_email string the default sender address for the template, if provided
 87:      *     - publish_from_name string the default sender from name for the template, if provided
 88:      *     - publish_text string the default text part of messages sent with the template, if provided
 89:      *     - published_at string the date and time the template was last published as a UTC string in YYYY-MM-DD HH:MM:SS format, or null if it has not been published
 90:      *     - created_at string the date and time the template was first created as a UTC string in YYYY-MM-DD HH:MM:SS format
 91:      *     - updated_at string the date and time the template was last modified as a UTC string in YYYY-MM-DD HH:MM:SS format
 92:      */
 93:     public function update($name, $from_email=null, $from_name=null, $subject=null, $code=null, $text=null, $publish=true) {
 94:         $_params = array("name" => $name, "from_email" => $from_email, "from_name" => $from_name, "subject" => $subject, "code" => $code, "text" => $text, "publish" => $publish);
 95:         return $this->master->call('templates/update', $_params);
 96:     }
 97: 
 98:     /**
 99:      * Publish the content for the template. Any new messages sent using this template will start using the content that was previously in draft.
100:      * @param string $name the immutable name of an existing template
101:      * @return struct the template that was published
102:      *     - slug string the immutable unique code name of the template
103:      *     - name string the name of the template
104:      *     - code string the full HTML code of the template, with mc:edit attributes marking the editable elements - draft version
105:      *     - subject string the subject line of the template, if provided - draft version
106:      *     - from_email string the default sender address for the template, if provided - draft version
107:      *     - from_name string the default sender from name for the template, if provided - draft version
108:      *     - text string the default text part of messages sent with the template, if provided - draft version
109:      *     - publish_name string the same as the template name - kept as a separate field for backwards compatibility
110:      *     - publish_code string the full HTML code of the template, with mc:edit attributes marking the editable elements that are available as published, if it has been published
111:      *     - publish_subject string the subject line of the template, if provided
112:      *     - publish_from_email string the default sender address for the template, if provided
113:      *     - publish_from_name string the default sender from name for the template, if provided
114:      *     - publish_text string the default text part of messages sent with the template, if provided
115:      *     - published_at string the date and time the template was last published as a UTC string in YYYY-MM-DD HH:MM:SS format, or null if it has not been published
116:      *     - created_at string the date and time the template was first created as a UTC string in YYYY-MM-DD HH:MM:SS format
117:      *     - updated_at string the date and time the template was last modified as a UTC string in YYYY-MM-DD HH:MM:SS format
118:      */
119:     public function publish($name) {
120:         $_params = array("name" => $name);
121:         return $this->master->call('templates/publish', $_params);
122:     }
123: 
124:     /**
125:      * Delete a template
126:      * @param string $name the immutable name of an existing template
127:      * @return struct the template that was deleted
128:      *     - slug string the immutable unique code name of the template
129:      *     - name string the name of the template
130:      *     - code string the full HTML code of the template, with mc:edit attributes marking the editable elements - draft version
131:      *     - subject string the subject line of the template, if provided - draft version
132:      *     - from_email string the default sender address for the template, if provided - draft version
133:      *     - from_name string the default sender from name for the template, if provided - draft version
134:      *     - text string the default text part of messages sent with the template, if provided - draft version
135:      *     - publish_name string the same as the template name - kept as a separate field for backwards compatibility
136:      *     - publish_code string the full HTML code of the template, with mc:edit attributes marking the editable elements that are available as published, if it has been published
137:      *     - publish_subject string the subject line of the template, if provided
138:      *     - publish_from_email string the default sender address for the template, if provided
139:      *     - publish_from_name string the default sender from name for the template, if provided
140:      *     - publish_text string the default text part of messages sent with the template, if provided
141:      *     - published_at string the date and time the template was last published as a UTC string in YYYY-MM-DD HH:MM:SS format, or null if it has not been published
142:      *     - created_at string the date and time the template was first created as a UTC string in YYYY-MM-DD HH:MM:SS format
143:      *     - updated_at string the date and time the template was last modified as a UTC string in YYYY-MM-DD HH:MM:SS format
144:      */
145:     public function delete($name) {
146:         $_params = array("name" => $name);
147:         return $this->master->call('templates/delete', $_params);
148:     }
149: 
150:     /**
151:      * Return a list of all the templates available to this user
152:      * @return array an array of structs with information about each template
153:      *     - return[] struct the information on each template in the account
154:      *         - slug string the immutable unique code name of the template
155:      *         - name string the name of the template
156:      *         - code string the full HTML code of the template, with mc:edit attributes marking the editable elements - draft version
157:      *         - subject string the subject line of the template, if provided - draft version
158:      *         - from_email string the default sender address for the template, if provided - draft version
159:      *         - from_name string the default sender from name for the template, if provided - draft version
160:      *         - text string the default text part of messages sent with the template, if provided - draft version
161:      *         - publish_name string the same as the template name - kept as a separate field for backwards compatibility
162:      *         - publish_code string the full HTML code of the template, with mc:edit attributes marking the editable elements that are available as published, if it has been published
163:      *         - publish_subject string the subject line of the template, if provided
164:      *         - publish_from_email string the default sender address for the template, if provided
165:      *         - publish_from_name string the default sender from name for the template, if provided
166:      *         - publish_text string the default text part of messages sent with the template, if provided
167:      *         - published_at string the date and time the template was last published as a UTC string in YYYY-MM-DD HH:MM:SS format, or null if it has not been published
168:      *         - created_at string the date and time the template was first created as a UTC string in YYYY-MM-DD HH:MM:SS format
169:      *         - updated_at string the date and time the template was last modified as a UTC string in YYYY-MM-DD HH:MM:SS format
170:      */
171:     public function getList() {
172:         $_params = array();
173:         return $this->master->call('templates/list', $_params);
174:     }
175: 
176:     /**
177:      * Return the recent history (hourly stats for the last 30 days) for a template
178:      * @param string $name the name of an existing template
179:      * @return array the array of history information
180:      *     - return[] struct the stats for a single hour
181:      *         - time string the hour as a UTC date string in YYYY-MM-DD HH:MM:SS format
182:      *         - sent integer the number of emails that were sent during the hour
183:      *         - hard_bounces integer the number of emails that hard bounced during the hour
184:      *         - soft_bounces integer the number of emails that soft bounced during the hour
185:      *         - rejects integer the number of emails that were rejected during the hour
186:      *         - complaints integer the number of spam complaints received during the hour
187:      *         - opens integer the number of emails opened during the hour
188:      *         - unique_opens integer the number of unique opens generated by messages sent during the hour
189:      *         - clicks integer the number of tracked URLs clicked during the hour
190:      *         - unique_clicks integer the number of unique clicks generated by messages sent during the hour
191:      */
192:     public function timeSeries($name) {
193:         $_params = array("name" => $name);
194:         return $this->master->call('templates/time-series', $_params);
195:     }
196: 
197:     /**
198:      * Inject content and optionally merge fields into a template, returning the HTML that results
199:      * @param string $template_name the immutable name of a template that exists in the user's account
200:      * @param array $template_content an array of template content to render.  Each item in the array should be a struct with two keys - name: the name of the content block to set the content for, and content: the actual content to put into the block
201:      *     - template_content[] struct the injection of a single piece of content into a single editable region
202:      *         - name string the name of the mc:edit editable region to inject into
203:      *         - content string the content to inject
204:      * @param array $merge_vars optional merge variables to use for injecting merge field content.  If this is not provided, no merge fields will be replaced.
205:      *     - merge_vars[] struct a single merge variable
206:      *         - name string the merge variable's name. Merge variable names are case-insensitive and may not start with _
207:      *         - content string the merge variable's content
208:      * @return struct the result of rendering the given template with the content and merge field values injected
209:      *     - html string the rendered HTML as a string
210:      */
211:     public function render($template_name, $template_content, $merge_vars=null) {
212:         $_params = array("template_name" => $template_name, "template_content" => $template_content, "merge_vars" => $merge_vars);
213:         return $this->master->call('templates/render', $_params);
214:     }
215: 
216: }
217: 
218: 
219: 
API documentation generated by ApiGen 2.8.0