@@ -223,6 +223,89 @@ public function testAuth() {
223
223
$ this ->SmtpTransport ->auth ();
224
224
}
225
225
226
+ /**
227
+ * testAuthNotRecognized method
228
+ *
229
+ * @expectedException SocketException
230
+ * @expectedExceptionMessage AUTH command not recognized or not implemented, SMTP server may not require authentication.
231
+ * @return void
232
+ */
233
+ public function testAuthNotRecognized () {
234
+ $ this ->socket ->expects ($ this ->at (0 ))->method ('write ' )->with ("AUTH LOGIN \r\n" );
235
+ $ this ->socket ->expects ($ this ->at (1 ))->method ('read ' )->will ($ this ->returnValue (false ));
236
+ $ this ->socket ->expects ($ this ->at (2 ))->method ('read ' )->will ($ this ->returnValue ("500 5.3.3 Unrecognized command \r\n" ));
237
+ $ this ->SmtpTransport ->config (array ('username ' => 'mark ' , 'password ' => 'story ' ));
238
+ $ this ->SmtpTransport ->auth ();
239
+ }
240
+
241
+ /**
242
+ * testAuthNotImplemented method
243
+ *
244
+ * @expectedException SocketException
245
+ * @expectedExceptionMessage AUTH command not recognized or not implemented, SMTP server may not require authentication.
246
+ * @return void
247
+ */
248
+ public function testAuthNotImplemented () {
249
+ $ this ->socket ->expects ($ this ->at (0 ))->method ('write ' )->with ("AUTH LOGIN \r\n" );
250
+ $ this ->socket ->expects ($ this ->at (1 ))->method ('read ' )->will ($ this ->returnValue (false ));
251
+ $ this ->socket ->expects ($ this ->at (2 ))->method ('read ' )->will ($ this ->returnValue ("502 5.3.3 Command not implemented \r\n" ));
252
+ $ this ->SmtpTransport ->config (array ('username ' => 'mark ' , 'password ' => 'story ' ));
253
+ $ this ->SmtpTransport ->auth ();
254
+ }
255
+
256
+ /**
257
+ * testAuthBadSequence method
258
+ *
259
+ * @expectedException SocketException
260
+ * @return void
261
+ */
262
+ public function testAuthBadSequence () {
263
+ $ this ->socket ->expects ($ this ->at (0 ))->method ('write ' )->with ("AUTH LOGIN \r\n" );
264
+ $ this ->socket ->expects ($ this ->at (1 ))->method ('read ' )->will ($ this ->returnValue (false ));
265
+ $ this ->socket ->expects ($ this ->at (2 ))->method ('read ' )->will ($ this ->returnValue ("503 5.5.1 Already authenticated \r\n" ));
266
+ $ this ->SmtpTransport ->config (array ('username ' => 'mark ' , 'password ' => 'story ' ));
267
+ $ this ->SmtpTransport ->auth ();
268
+ }
269
+
270
+ /**
271
+ * testAuthBadUsername method
272
+ *
273
+ * @expectedException SocketException
274
+ * @expectedExceptionMessage SMTP server did not accept the username.
275
+ * @return void
276
+ */
277
+ public function testAuthBadUsername () {
278
+ $ this ->socket ->expects ($ this ->at (0 ))->method ('write ' )->with ("AUTH LOGIN \r\n" );
279
+ $ this ->socket ->expects ($ this ->at (1 ))->method ('read ' )->will ($ this ->returnValue (false ));
280
+ $ this ->socket ->expects ($ this ->at (2 ))->method ('read ' )->will ($ this ->returnValue ("334 Login \r\n" ));
281
+ $ this ->socket ->expects ($ this ->at (3 ))->method ('write ' )->with ("bWFyaw== \r\n" );
282
+ $ this ->socket ->expects ($ this ->at (4 ))->method ('read ' )->will ($ this ->returnValue (false ));
283
+ $ this ->socket ->expects ($ this ->at (5 ))->method ('read ' )->will ($ this ->returnValue ("535 5.7.8 Authentication failed \r\n" ));
284
+ $ this ->SmtpTransport ->config (array ('username ' => 'mark ' , 'password ' => 'story ' ));
285
+ $ this ->SmtpTransport ->auth ();
286
+ }
287
+
288
+ /**
289
+ * testAuthBadPassword method
290
+ *
291
+ * @expectedException SocketException
292
+ * @expectedExceptionMessage SMTP server did not accept the password.
293
+ * @return void
294
+ */
295
+ public function testAuthBadPassword () {
296
+ $ this ->socket ->expects ($ this ->at (0 ))->method ('write ' )->with ("AUTH LOGIN \r\n" );
297
+ $ this ->socket ->expects ($ this ->at (1 ))->method ('read ' )->will ($ this ->returnValue (false ));
298
+ $ this ->socket ->expects ($ this ->at (2 ))->method ('read ' )->will ($ this ->returnValue ("334 Login \r\n" ));
299
+ $ this ->socket ->expects ($ this ->at (3 ))->method ('write ' )->with ("bWFyaw== \r\n" );
300
+ $ this ->socket ->expects ($ this ->at (4 ))->method ('read ' )->will ($ this ->returnValue (false ));
301
+ $ this ->socket ->expects ($ this ->at (5 ))->method ('read ' )->will ($ this ->returnValue ("334 Pass \r\n" ));
302
+ $ this ->socket ->expects ($ this ->at (6 ))->method ('write ' )->with ("c3Rvcnk= \r\n" );
303
+ $ this ->socket ->expects ($ this ->at (7 ))->method ('read ' )->will ($ this ->returnValue (false ));
304
+ $ this ->socket ->expects ($ this ->at (8 ))->method ('read ' )->will ($ this ->returnValue ("535 5.7.8 Authentication failed \r\n" ));
305
+ $ this ->SmtpTransport ->config (array ('username ' => 'mark ' , 'password ' => 'story ' ));
306
+ $ this ->SmtpTransport ->auth ();
307
+ }
308
+
226
309
/**
227
310
* testAuthNoAuth method
228
311
*
0 commit comments