Rejects.php 4.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <?php
  2. class Mandrill_Rejects {
  3. public function __construct(Mandrill $master) {
  4. $this->master = $master;
  5. }
  6. /**
  7. * Adds an email to your email rejection blacklist. Addresses that you
  8. add manually will never expire and there is no reputation penalty
  9. for removing them from your blacklist. Attempting to blacklist an
  10. address that has been whitelisted will have no effect.
  11. * @param string $email an email address to block
  12. * @param string $comment an optional comment describing the rejection
  13. * @param string $subaccount an optional unique identifier for the subaccount to limit the blacklist entry
  14. * @return struct a status object containing the address and the result of the operation
  15. * - email string the email address you provided
  16. * - added boolean whether the operation succeeded
  17. */
  18. public function add($email, $comment=null, $subaccount=null) {
  19. $_params = array("email" => $email, "comment" => $comment, "subaccount" => $subaccount);
  20. return $this->master->call('rejects/add', $_params);
  21. }
  22. /**
  23. * Retrieves your email rejection blacklist. You can provide an email
  24. address to limit the results. Returns up to 1000 results. By default,
  25. entries that have expired are excluded from the results; set
  26. include_expired to true to include them.
  27. * @param string $email an optional email address to search by
  28. * @param boolean $include_expired whether to include rejections that have already expired.
  29. * @param string $subaccount an optional unique identifier for the subaccount to limit the blacklist
  30. * @return array Up to 1000 rejection entries
  31. * - return[] struct the information for each rejection blacklist entry
  32. * - email string the email that is blocked
  33. * - reason string the type of event (hard-bounce, soft-bounce, spam, unsub) that caused this rejection
  34. * - detail string extended details about the event, such as the SMTP diagnostic for bounces or the comment for manually-created rejections
  35. * - created_at string when the email was added to the blacklist
  36. * - last_event_at string the timestamp of the most recent event that either created or renewed this rejection
  37. * - expires_at string when the blacklist entry will expire (this may be in the past)
  38. * - expired boolean whether the blacklist entry has expired
  39. * - sender struct the sender that this blacklist entry applies to, or null if none.
  40. * - address string the sender's email address
  41. * - 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
  42. * - sent integer the total number of messages sent by this sender
  43. * - hard_bounces integer the total number of hard bounces by messages by this sender
  44. * - soft_bounces integer the total number of soft bounces by messages by this sender
  45. * - rejects integer the total number of rejected messages by this sender
  46. * - complaints integer the total number of spam complaints received for messages by this sender
  47. * - unsubs integer the total number of unsubscribe requests received for messages by this sender
  48. * - opens integer the total number of times messages by this sender have been opened
  49. * - clicks integer the total number of times tracked URLs in messages by this sender have been clicked
  50. * - unique_opens integer the number of unique opens for emails sent for this sender
  51. * - unique_clicks integer the number of unique clicks for emails sent for this sender
  52. * - subaccount string the subaccount that this blacklist entry applies to, or null if none.
  53. */
  54. public function getList($email=null, $include_expired=false, $subaccount=null) {
  55. $_params = array("email" => $email, "include_expired" => $include_expired, "subaccount" => $subaccount);
  56. return $this->master->call('rejects/list', $_params);
  57. }
  58. /**
  59. * Deletes an email rejection. There is no limit to how many rejections
  60. you can remove from your blacklist, but keep in mind that each deletion
  61. has an affect on your reputation.
  62. * @param string $email an email address
  63. * @param string $subaccount an optional unique identifier for the subaccount to limit the blacklist deletion
  64. * @return struct a status object containing the address and whether the deletion succeeded.
  65. * - email string the email address that was removed from the blacklist
  66. * - deleted boolean whether the address was deleted successfully.
  67. * - subaccount string the subaccount blacklist that the address was removed from, if any
  68. */
  69. public function delete($email, $subaccount=null) {
  70. $_params = array("email" => $email, "subaccount" => $subaccount);
  71. return $this->master->call('rejects/delete', $_params);
  72. }
  73. }