@@ -88,7 +88,6 @@ public function __construct($emails = array(), $sender = '', $options = array())
88
88
$ emailBag ->add ((array )$ emails );
89
89
$ domainBag = $ this ->setEmailsDomains ($ emailBag );
90
90
$ this ->domains = $ domainBag ->all ();
91
-
92
91
}
93
92
94
93
if (!empty ($ sender )) {
@@ -132,86 +131,85 @@ public function __construct($emails = array(), $sender = '', $options = array())
132
131
133
132
} catch (ExceptionNoConnection $ e ) {
134
133
// unable to connect to host, so these addresses are invalid?
135
- $ this ->setDomainResults ($ users , $ dom , 0 );
134
+ $ this ->setDomainResults ($ users , $ dom , 0 , ' unable to connect to host ' );
136
135
}
137
136
}
138
- try {
139
- // are we connected?
140
- if ($ smtp ->isConnect ()) {
141
137
138
+ // are we connected?
139
+ if ($ smtp ->isConnect ()) {
142
140
143
- sleep ($ options ['delaySleep ' ][$ i ]);
144
141
145
- // say helo, and continue if we can talk
146
- if ($ smtp ->helo ()) {
142
+ sleep ($ options ['delaySleep ' ][$ i ]);
147
143
148
- // try issuing MAIL FROM
149
- if (!($ smtp ->mail ($ this ->fromUser . '@ ' . $ this ->fromDomain ))) {
150
- // MAIL FROM not accepted, we can't talk
151
- $ this ->setDomainResults ($ users , $ dom , $ options ['noCommIsValid ' ]);
152
- }
144
+ // say helo, and continue if we can talk
145
+ if ($ smtp ->helo ()) {
153
146
154
- /**
155
- * if we're still connected, proceed (cause we might get
156
- * disconnected, or banned, or greylisted temporarily etc.)
157
- * see mail() for more
158
- */
159
- if ($ smtp ->isConnect ()) {
147
+ // try issuing MAIL FROM
148
+ if (!($ smtp ->mail ($ this ->fromUser . '@ ' . $ this ->fromDomain ))) {
149
+ // MAIL FROM not accepted, we can't talk
150
+ $ this ->setDomainResults ($ users , $ dom , $ options ['noCommIsValid ' ],'MAIL FROM not accepted ' );
151
+ }
152
+
153
+ /**
154
+ * if we're still connected, proceed (cause we might get
155
+ * disconnected, or banned, or greylisted temporarily etc.)
156
+ * see mail() for more
157
+ */
158
+ if ( $ smtp ->isConnect ()) {
159
+
160
+ $ smtp ->noop ();
161
+
162
+ // Do a catch-all test for the domain always.
163
+ // This increases checking time for a domain slightly,
164
+ // but doesn't confuse users.
165
+ try {
166
+ $ isCatchallDomain = $ smtp ->acceptsAnyRecipient ($ dom );
167
+ }catch (\Exception $ e ) {
168
+ $ this ->setDomainResults ($ users , $ dom , $ options ['catchAllIsValid ' ], 'error while on CatchAll test: ' .$ e );
169
+ }
160
170
161
- $ smtp ->noop ();
162
171
163
- // Do a catch-all test for the domain always.
164
- // This increases checking time for a domain slightly,
165
- // but doesn't confuse users.
166
- try {
167
- $ isCatchallDomain = $ smtp -> acceptsAnyRecipient ( $ dom );
168
- } catch ( \ Exception $ e ) {
169
- $ this -> setDomainResults ( $ users , $ dom , $ options [ ' catchAllIsValid ' ]) ;
172
+ // if a catchall domain is detected, and we consider
173
+ // accounts on such domains as invalid, mark all the
174
+ // users as invalid and move on
175
+ if ( $ isCatchallDomain ) {
176
+ if (! $ options [ ' catchAllIsValid ' ]) {
177
+ $ this -> setDomainResults ( $ users , $ dom , $ options [ ' catchAllIsValid ' ], ' catch all detected ' );
178
+ continue ;
170
179
}
180
+ }
171
181
182
+ // if we're still connected, try issuing rcpts
183
+ if ($ smtp ->isConnect ()) {
184
+ $ smtp ->noop ();
185
+ // rcpt to for each user
186
+ foreach ($ users as $ user ) {
187
+ $ address = $ user . '@ ' . $ dom ->getDomain ();
188
+ $ this ->results [$ address ] = $ smtp ->rcpt ($ address );
172
189
173
- // if a catchall domain is detected, and we consider
174
- // accounts on such domains as invalid, mark all the
175
- // users as invalid and move on
176
- if ($ isCatchallDomain ) {
177
- if (!$ options ['catchAllIsValid ' ]) {
178
- $ this ->setDomainResults ($ users , $ dom , $ options ['catchAllIsValid ' ]);
179
- continue ;
190
+ if ($ this ->results [$ address ] == 1 ) {
191
+ $ loopStop = 1 ;
180
192
}
181
- }
182
-
183
- // if we're still connected, try issuing rcpts
184
- if ($ smtp ->isConnect ()) {
185
193
$ smtp ->noop ();
186
- // rcpt to for each user
187
- foreach ($ users as $ user ) {
188
- $ address = $ user . '@ ' . $ dom ->getDomain ();
189
- $ this ->results [$ address ] = $ smtp ->rcpt ($ address );
190
-
191
- if ($ this ->results [$ address ] == 1 ) {
192
- $ loopStop = 1 ;
193
- }
194
- $ smtp ->noop ();
195
- }
196
- }
197
-
198
- // saying buh-bye if we're still connected, cause we're done here
199
- if ($ smtp ->isConnect ()) {
200
- // issue a rset for all the things we just made the MTA do
201
- $ smtp ->rset ();
202
- // kiss it goodbye
203
- $ smtp ->disconnect ();
204
194
}
195
+ }
205
196
197
+ // saying buh-bye if we're still connected, cause we're done here
198
+ if ($ smtp ->isConnect ()) {
199
+ // issue a rset for all the things we just made the MTA do
200
+ $ smtp ->rset ();
201
+ // kiss it goodbye
202
+ $ smtp ->disconnect ();
206
203
}
207
204
208
- } else {
209
- // we didn't get a good response to helo and should be disconnected already
210
- $ this ->setDomainResults ($ users , $ dom , $ options ['noCommIsValid ' ]);
211
205
}
206
+
207
+ } else {
208
+ // we didn't get a good response to helo and should be disconnected already
209
+ $ this ->setDomainResults ($ users , $ dom , $ options ['noCommIsValid ' ],'bad response on helo ' );
212
210
}
213
- } catch ( \ Exception $ e ) {
214
- $ this ->setDomainResults ($ users , $ dom , 0 );
211
+ } else {
212
+ $ this ->setDomainResults ($ users , $ dom , 0 , ' no connection ' );
215
213
}
216
214
217
215
if ($ options ['domainMoreInfo ' ]) {
@@ -284,15 +282,20 @@ public function setSender($email)
284
282
* @param array $users Array of users (usernames)
285
283
* @param Domain $domain The domain
286
284
* @param int $val Value to set
285
+ * @param String $info Optional , can be used to give additional information about the result
287
286
*/
288
- private function setDomainResults ($ users , Domain $ domain , $ val )
287
+ private function setDomainResults ($ users , Domain $ domain , $ val, $ info = '' )
289
288
{
289
+ echo 'setDomain Called ' ;
290
290
if (!is_array ($ users )) {
291
291
$ users = (array )$ users ;
292
292
}
293
293
294
294
foreach ($ users as $ user ) {
295
- $ this ->results [$ user . '@ ' . $ domain ->getDomain ()] = $ val ;
295
+ $ this ->results [$ user . '@ ' . $ domain ->getDomain ()] = [
296
+ 'result ' => $ val ,
297
+ 'info ' => $ info
298
+ ];
296
299
}
297
300
}
298
301
}
0 commit comments