Senders.php 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. <?php
  2. class Mandrill_Senders {
  3. public function __construct(Mandrill $master) {
  4. $this->master = $master;
  5. }
  6. /**
  7. * Return the senders that have tried to use this account.
  8. * @return array an array of sender data, one for each sending addresses used by the account
  9. * - return[] struct the information on each sending address in the account
  10. * - address string the sender's email address
  11. * - created_at string the date and time that the sender was first seen by Mandrill as a UTC date string in YYYY-MM-DD HH:MM:SS format
  12. * - sent integer the total number of messages sent by this sender
  13. * - hard_bounces integer the total number of hard bounces by messages by this sender
  14. * - soft_bounces integer the total number of soft bounces by messages by this sender
  15. * - rejects integer the total number of rejected messages by this sender
  16. * - complaints integer the total number of spam complaints received for messages by this sender
  17. * - unsubs integer the total number of unsubscribe requests received for messages by this sender
  18. * - opens integer the total number of times messages by this sender have been opened
  19. * - clicks integer the total number of times tracked URLs in messages by this sender have been clicked
  20. * - unique_opens integer the number of unique opens for emails sent for this sender
  21. * - unique_clicks integer the number of unique clicks for emails sent for this sender
  22. */
  23. public function getList() {
  24. $_params = array();
  25. return $this->master->call('senders/list', $_params);
  26. }
  27. /**
  28. * Returns the sender domains that have been added to this account.
  29. * @return array an array of sender domain data, one for each sending domain used by the account
  30. * - return[] struct the information on each sending domain for the account
  31. * - domain string the sender domain name
  32. * - created_at string the date and time that the sending domain was first seen as a UTC string in YYYY-MM-DD HH:MM:SS format
  33. * - last_tested_at string when the domain's DNS settings were last tested as a UTC string in YYYY-MM-DD HH:MM:SS format
  34. * - spf struct details about the domain's SPF record
  35. * - valid boolean whether the domain's SPF record is valid for use with Mandrill
  36. * - valid_after string when the domain's SPF record will be considered valid for use with Mandrill as a UTC string in YYYY-MM-DD HH:MM:SS format. If set, this indicates that the record is valid now, but was previously invalid, and Mandrill will wait until the record's TTL elapses to start using it.
  37. * - error string an error describing the spf record, or null if the record is correct
  38. * - dkim struct details about the domain's DKIM record
  39. * - valid boolean whether the domain's DKIM record is valid for use with Mandrill
  40. * - valid_after string when the domain's DKIM record will be considered valid for use with Mandrill as a UTC string in YYYY-MM-DD HH:MM:SS format. If set, this indicates that the record is valid now, but was previously invalid, and Mandrill will wait until the record's TTL elapses to start using it.
  41. * - error string an error describing the DKIM record, or null if the record is correct
  42. * - verified_at string if the domain has been verified, this indicates when that verification occurred as a UTC string in YYYY-MM-DD HH:MM:SS format
  43. * - valid_signing boolean whether this domain can be used to authenticate mail, either for itself or as a custom signing domain. If this is false but spf and dkim are both valid, you will need to verify the domain before using it to authenticate mail
  44. */
  45. public function domains() {
  46. $_params = array();
  47. return $this->master->call('senders/domains', $_params);
  48. }
  49. /**
  50. * Adds a sender domain to your account. Sender domains are added automatically as you
  51. send, but you can use this call to add them ahead of time.
  52. * @param string $domain a domain name
  53. * @return struct information about the domain
  54. * - domain string the sender domain name
  55. * - created_at string the date and time that the sending domain was first seen as a UTC string in YYYY-MM-DD HH:MM:SS format
  56. * - last_tested_at string when the domain's DNS settings were last tested as a UTC string in YYYY-MM-DD HH:MM:SS format
  57. * - spf struct details about the domain's SPF record
  58. * - valid boolean whether the domain's SPF record is valid for use with Mandrill
  59. * - valid_after string when the domain's SPF record will be considered valid for use with Mandrill as a UTC string in YYYY-MM-DD HH:MM:SS format. If set, this indicates that the record is valid now, but was previously invalid, and Mandrill will wait until the record's TTL elapses to start using it.
  60. * - error string an error describing the spf record, or null if the record is correct
  61. * - dkim struct details about the domain's DKIM record
  62. * - valid boolean whether the domain's DKIM record is valid for use with Mandrill
  63. * - valid_after string when the domain's DKIM record will be considered valid for use with Mandrill as a UTC string in YYYY-MM-DD HH:MM:SS format. If set, this indicates that the record is valid now, but was previously invalid, and Mandrill will wait until the record's TTL elapses to start using it.
  64. * - error string an error describing the DKIM record, or null if the record is correct
  65. * - verified_at string if the domain has been verified, this indicates when that verification occurred as a UTC string in YYYY-MM-DD HH:MM:SS format
  66. * - valid_signing boolean whether this domain can be used to authenticate mail, either for itself or as a custom signing domain. If this is false but spf and dkim are both valid, you will need to verify the domain before using it to authenticate mail
  67. */
  68. public function addDomain($domain) {
  69. $_params = array("domain" => $domain);
  70. return $this->master->call('senders/add-domain', $_params);
  71. }
  72. /**
  73. * Checks the SPF and DKIM settings for a domain. If you haven't already added this domain to your
  74. account, it will be added automatically.
  75. * @param string $domain a domain name
  76. * @return struct information about the sender domain
  77. * - domain string the sender domain name
  78. * - created_at string the date and time that the sending domain was first seen as a UTC string in YYYY-MM-DD HH:MM:SS format
  79. * - last_tested_at string when the domain's DNS settings were last tested as a UTC string in YYYY-MM-DD HH:MM:SS format
  80. * - spf struct details about the domain's SPF record
  81. * - valid boolean whether the domain's SPF record is valid for use with Mandrill
  82. * - valid_after string when the domain's SPF record will be considered valid for use with Mandrill as a UTC string in YYYY-MM-DD HH:MM:SS format. If set, this indicates that the record is valid now, but was previously invalid, and Mandrill will wait until the record's TTL elapses to start using it.
  83. * - error string an error describing the spf record, or null if the record is correct
  84. * - dkim struct details about the domain's DKIM record
  85. * - valid boolean whether the domain's DKIM record is valid for use with Mandrill
  86. * - valid_after string when the domain's DKIM record will be considered valid for use with Mandrill as a UTC string in YYYY-MM-DD HH:MM:SS format. If set, this indicates that the record is valid now, but was previously invalid, and Mandrill will wait until the record's TTL elapses to start using it.
  87. * - error string an error describing the DKIM record, or null if the record is correct
  88. * - verified_at string if the domain has been verified, this indicates when that verification occurred as a UTC string in YYYY-MM-DD HH:MM:SS format
  89. * - valid_signing boolean whether this domain can be used to authenticate mail, either for itself or as a custom signing domain. If this is false but spf and dkim are both valid, you will need to verify the domain before using it to authenticate mail
  90. */
  91. public function checkDomain($domain) {
  92. $_params = array("domain" => $domain);
  93. return $this->master->call('senders/check-domain', $_params);
  94. }
  95. /**
  96. * Sends a verification email in order to verify ownership of a domain.
  97. Domain verification is an optional step to confirm ownership of a domain. Once a
  98. domain has been verified in a Mandrill account, other accounts may not have their
  99. messages signed by that domain unless they also verify the domain. This prevents
  100. other Mandrill accounts from sending mail signed by your domain.
  101. * @param string $domain a domain name at which you can receive email
  102. * @param string $mailbox a mailbox at the domain where the verification email should be sent
  103. * @return struct information about the verification that was sent
  104. * - status string "sent" indicates that the verification has been sent, "already_verified" indicates that the domain has already been verified with your account
  105. * - domain string the domain name you provided
  106. * - email string the email address the verification email was sent to
  107. */
  108. public function verifyDomain($domain, $mailbox) {
  109. $_params = array("domain" => $domain, "mailbox" => $mailbox);
  110. return $this->master->call('senders/verify-domain', $_params);
  111. }
  112. /**
  113. * Return more detailed information about a single sender, including aggregates of recent stats
  114. * @param string $address the email address of the sender
  115. * @return struct the detailed information on the sender
  116. * - address string the sender's email address
  117. * - created_at string the date and time that the sender was first seen by Mandrill as a UTC date string in YYYY-MM-DD HH:MM:SS format
  118. * - sent integer the total number of messages sent by this sender
  119. * - hard_bounces integer the total number of hard bounces by messages by this sender
  120. * - soft_bounces integer the total number of soft bounces by messages by this sender
  121. * - rejects integer the total number of rejected messages by this sender
  122. * - complaints integer the total number of spam complaints received for messages by this sender
  123. * - unsubs integer the total number of unsubscribe requests received for messages by this sender
  124. * - opens integer the total number of times messages by this sender have been opened
  125. * - clicks integer the total number of times tracked URLs in messages by this sender have been clicked
  126. * - stats struct an aggregate summary of the sender's sending stats
  127. * - today struct stats for this sender so far today
  128. * - sent integer the number of emails sent for this sender so far today
  129. * - hard_bounces integer the number of emails hard bounced for this sender so far today
  130. * - soft_bounces integer the number of emails soft bounced for this sender so far today
  131. * - rejects integer the number of emails rejected for sending this sender so far today
  132. * - complaints integer the number of spam complaints for this sender so far today
  133. * - unsubs integer the number of unsubscribes for this sender so far today
  134. * - opens integer the number of times emails have been opened for this sender so far today
  135. * - unique_opens integer the number of unique opens for emails sent for this sender so far today
  136. * - clicks integer the number of URLs that have been clicked for this sender so far today
  137. * - unique_clicks integer the number of unique clicks for emails sent for this sender so far today
  138. * - last_7_days struct stats for this sender in the last 7 days
  139. * - sent integer the number of emails sent for this sender in the last 7 days
  140. * - hard_bounces integer the number of emails hard bounced for this sender in the last 7 days
  141. * - soft_bounces integer the number of emails soft bounced for this sender in the last 7 days
  142. * - rejects integer the number of emails rejected for sending this sender in the last 7 days
  143. * - complaints integer the number of spam complaints for this sender in the last 7 days
  144. * - unsubs integer the number of unsubscribes for this sender in the last 7 days
  145. * - opens integer the number of times emails have been opened for this sender in the last 7 days
  146. * - unique_opens integer the number of unique opens for emails sent for this sender in the last 7 days
  147. * - clicks integer the number of URLs that have been clicked for this sender in the last 7 days
  148. * - unique_clicks integer the number of unique clicks for emails sent for this sender in the last 7 days
  149. * - last_30_days struct stats for this sender in the last 30 days
  150. * - sent integer the number of emails sent for this sender in the last 30 days
  151. * - hard_bounces integer the number of emails hard bounced for this sender in the last 30 days
  152. * - soft_bounces integer the number of emails soft bounced for this sender in the last 30 days
  153. * - rejects integer the number of emails rejected for sending this sender in the last 30 days
  154. * - complaints integer the number of spam complaints for this sender in the last 30 days
  155. * - unsubs integer the number of unsubscribes for this sender in the last 30 days
  156. * - opens integer the number of times emails have been opened for this sender in the last 30 days
  157. * - unique_opens integer the number of unique opens for emails sent for this sender in the last 30 days
  158. * - clicks integer the number of URLs that have been clicked for this sender in the last 30 days
  159. * - unique_clicks integer the number of unique clicks for emails sent for this sender in the last 30 days
  160. * - last_60_days struct stats for this sender in the last 60 days
  161. * - sent integer the number of emails sent for this sender in the last 60 days
  162. * - hard_bounces integer the number of emails hard bounced for this sender in the last 60 days
  163. * - soft_bounces integer the number of emails soft bounced for this sender in the last 60 days
  164. * - rejects integer the number of emails rejected for sending this sender in the last 60 days
  165. * - complaints integer the number of spam complaints for this sender in the last 60 days
  166. * - unsubs integer the number of unsubscribes for this sender in the last 60 days
  167. * - opens integer the number of times emails have been opened for this sender in the last 60 days
  168. * - unique_opens integer the number of unique opens for emails sent for this sender in the last 60 days
  169. * - clicks integer the number of URLs that have been clicked for this sender in the last 60 days
  170. * - unique_clicks integer the number of unique clicks for emails sent for this sender in the last 60 days
  171. * - last_90_days struct stats for this sender in the last 90 days
  172. * - sent integer the number of emails sent for this sender in the last 90 days
  173. * - hard_bounces integer the number of emails hard bounced for this sender in the last 90 days
  174. * - soft_bounces integer the number of emails soft bounced for this sender in the last 90 days
  175. * - rejects integer the number of emails rejected for sending this sender in the last 90 days
  176. * - complaints integer the number of spam complaints for this sender in the last 90 days
  177. * - unsubs integer the number of unsubscribes for this sender in the last 90 days
  178. * - opens integer the number of times emails have been opened for this sender in the last 90 days
  179. * - unique_opens integer the number of unique opens for emails sent for this sender in the last 90 days
  180. * - clicks integer the number of URLs that have been clicked for this sender in the last 90 days
  181. * - unique_clicks integer the number of unique clicks for emails sent for this sender in the last 90 days
  182. */
  183. public function info($address) {
  184. $_params = array("address" => $address);
  185. return $this->master->call('senders/info', $_params);
  186. }
  187. /**
  188. * Return the recent history (hourly stats for the last 30 days) for a sender
  189. * @param string $address the email address of the sender
  190. * @return array the array of history information
  191. * - return[] struct the stats for a single hour
  192. * - time string the hour as a UTC date string in YYYY-MM-DD HH:MM:SS format
  193. * - sent integer the number of emails that were sent during the hour
  194. * - hard_bounces integer the number of emails that hard bounced during the hour
  195. * - soft_bounces integer the number of emails that soft bounced during the hour
  196. * - rejects integer the number of emails that were rejected during the hour
  197. * - complaints integer the number of spam complaints received during the hour
  198. * - opens integer the number of emails opened during the hour
  199. * - unique_opens integer the number of unique opens generated by messages sent during the hour
  200. * - clicks integer the number of tracked URLs clicked during the hour
  201. * - unique_clicks integer the number of unique clicks generated by messages sent during the hour
  202. */
  203. public function timeSeries($address) {
  204. $_params = array("address" => $address);
  205. return $this->master->call('senders/time-series', $_params);
  206. }
  207. }