Passed
Push — master ( d156dd...acd975 )
by Thomas
04:20 queued 01:05
created

Mandrill_Inbound::domains()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 4
rs 10
1
<?php
2
3
class Mandrill_Inbound
4
{
5
6
    public function __construct(Mandrill $master)
7
    {
8
        $this->master = $master;
0 ignored issues
show
Bug Best Practice introduced by
The property master does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
9
    }
10
11
    /**
12
     * List the domains that have been configured for inbound delivery
13
     * @return array the inbound domains associated with the account
14
     *     - return[] struct the individual domain info
15
     *         - domain string the domain name that is accepting mail
16
     *         - created_at string the date and time that the inbound domain was added as a UTC string in YYYY-MM-DD HH:MM:SS format
17
     *         - valid_mx boolean true if this inbound domain has successfully set up an MX record to deliver mail to the Mandrill servers
18
     */
19
    public function domains()
20
    {
21
        $_params = array();
22
        return $this->master->call('inbound/domains', $_params);
23
    }
24
25
    /**
26
     * Add an inbound domain to your account
27
     * @param string $domain a domain name
28
     * @return struct information about the domain
0 ignored issues
show
Bug introduced by
The type struct was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
29
     *     - domain string the domain name that is accepting mail
30
     *     - created_at string the date and time that the inbound domain was added as a UTC string in YYYY-MM-DD HH:MM:SS format
31
     *     - valid_mx boolean true if this inbound domain has successfully set up an MX record to deliver mail to the Mandrill servers
32
     */
33
    public function addDomain($domain)
34
    {
35
        $_params = array("domain" => $domain);
36
        return $this->master->call('inbound/add-domain', $_params);
37
    }
38
39
    /**
40
     * Check the MX settings for an inbound domain. The domain must have already been added with the add-domain call
41
     * @param string $domain an existing inbound domain
42
     * @return struct information about the inbound domain
43
     *     - domain string the domain name that is accepting mail
44
     *     - created_at string the date and time that the inbound domain was added as a UTC string in YYYY-MM-DD HH:MM:SS format
45
     *     - valid_mx boolean true if this inbound domain has successfully set up an MX record to deliver mail to the Mandrill servers
46
     */
47
    public function checkDomain($domain)
48
    {
49
        $_params = array("domain" => $domain);
50
        return $this->master->call('inbound/check-domain', $_params);
51
    }
52
53
    /**
54
     * Delete an inbound domain from the account. All mail will stop routing for this domain immediately.
55
     * @param string $domain an existing inbound domain
56
     * @return struct information about the deleted domain
57
     *     - domain string the domain name that is accepting mail
58
     *     - created_at string the date and time that the inbound domain was added as a UTC string in YYYY-MM-DD HH:MM:SS format
59
     *     - valid_mx boolean true if this inbound domain has successfully set up an MX record to deliver mail to the Mandrill servers
60
     */
61
    public function deleteDomain($domain)
62
    {
63
        $_params = array("domain" => $domain);
64
        return $this->master->call('inbound/delete-domain', $_params);
65
    }
66
67
    /**
68
     * List the mailbox routes defined for an inbound domain
69
     * @param string $domain the domain to check
70
     * @return array the routes associated with the domain
71
     *     - return[] struct the individual mailbox route
72
     *         - id string the unique identifier of the route
73
     *         - pattern string the search pattern that the mailbox name should match
74
     *         - url string the webhook URL where inbound messages will be published
75
     */
76
    public function routes($domain)
77
    {
78
        $_params = array("domain" => $domain);
79
        return $this->master->call('inbound/routes', $_params);
80
    }
81
82
    /**
83
     * Add a new mailbox route to an inbound domain
84
     * @param string $domain an existing inbound domain
85
     * @param string $pattern the search pattern that the mailbox name should match
86
     * @param string $url the webhook URL where the inbound messages will be published
87
     * @return struct the added mailbox route information
88
     *     - id string the unique identifier of the route
89
     *     - pattern string the search pattern that the mailbox name should match
90
     *     - url string the webhook URL where inbound messages will be published
91
     */
92
    public function addRoute($domain, $pattern, $url)
93
    {
94
        $_params = array("domain" => $domain, "pattern" => $pattern, "url" => $url);
95
        return $this->master->call('inbound/add-route', $_params);
96
    }
97
98
    /**
99
     * Update the pattern or webhook of an existing inbound mailbox route. If null is provided for any fields, the values will remain unchanged.
100
     * @param string $id the unique identifier of an existing mailbox route
101
     * @param string $pattern the search pattern that the mailbox name should match
102
     * @param string $url the webhook URL where the inbound messages will be published
103
     * @return struct the updated mailbox route information
104
     *     - id string the unique identifier of the route
105
     *     - pattern string the search pattern that the mailbox name should match
106
     *     - url string the webhook URL where inbound messages will be published
107
     */
108
    public function updateRoute($id, $pattern = null, $url = null)
109
    {
110
        $_params = array("id" => $id, "pattern" => $pattern, "url" => $url);
111
        return $this->master->call('inbound/update-route', $_params);
112
    }
113
114
    /**
115
     * Delete an existing inbound mailbox route
116
     * @param string $id the unique identifier of an existing route
117
     * @return struct the deleted mailbox route information
118
     *     - id string the unique identifier of the route
119
     *     - pattern string the search pattern that the mailbox name should match
120
     *     - url string the webhook URL where inbound messages will be published
121
     */
122
    public function deleteRoute($id)
123
    {
124
        $_params = array("id" => $id);
125
        return $this->master->call('inbound/delete-route', $_params);
126
    }
127
128
    /**
129
     * Take a raw MIME document destined for a domain with inbound domains set up, and send it to the inbound hook exactly as if it had been sent over SMTP
130
     * @param string $raw_message the full MIME document of an email message
131
     * @param array|null $to optionally define the recipients to receive the message - otherwise we'll use the To, Cc, and Bcc headers provided in the document
132
     *     - to[] string the email address of the recipient
133
     * @param string $mail_from the address specified in the MAIL FROM stage of the SMTP conversation. Required for the SPF check.
134
     * @param string $helo the identification provided by the client mta in the MTA state of the SMTP conversation. Required for the SPF check.
135
     * @param string $client_address the remote MTA's ip address. Optional; required for the SPF check.
136
     * @return array an array of the information for each recipient in the message (usually one) that matched an inbound route
137
     *     - return[] struct the individual recipient information
138
     *         - email string the email address of the matching recipient
139
     *         - pattern string the mailbox route pattern that the recipient matched
140
     *         - url string the webhook URL that the message was posted to
141
     */
142
    public function sendRaw($raw_message, $to = null, $mail_from = null, $helo = null, $client_address = null)
143
    {
144
        $_params = array("raw_message" => $raw_message, "to" => $to, "mail_from" => $mail_from, "helo" => $helo, "client_address" => $client_address);
145
        return $this->master->call('inbound/send-raw', $_params);
146
    }
147
}
148