1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Kodus\Mail\Test\Integration; |
4
|
|
|
|
5
|
|
|
use IntegrationTester; |
6
|
|
|
use Kodus\Mail\Address; |
7
|
|
|
use Kodus\Mail\Message; |
8
|
|
|
use Kodus\Mail\SMTP\Authenticator\NoAuthenticator; |
9
|
|
|
use Kodus\Mail\SMTP\SMTPMailService; |
10
|
|
|
use Kodus\Mail\Test\TestMessageFactory; |
11
|
|
|
|
12
|
|
|
class MailServiceCest |
13
|
|
|
{ |
14
|
|
|
/** |
15
|
|
|
* In this test, we connect using a plain socket without login authentication, then |
16
|
|
|
* attempt to send every kind of test-message implemented by the Test Message Factory. |
17
|
|
|
*/ |
18
|
|
|
public function sendMail(IntegrationTester $I) |
19
|
|
|
{ |
20
|
|
|
$factory = new TestMessageFactory(); |
21
|
|
|
|
22
|
|
|
$client_domain = "localhost"; |
23
|
|
|
|
24
|
|
|
$service = new SMTPMailService( |
25
|
|
|
$I->createSocketConnector(), new NoAuthenticator(), $client_domain |
26
|
|
|
); |
27
|
|
|
|
28
|
|
|
$messages = $factory->createAllMessageTypes(); |
29
|
|
|
|
30
|
|
|
foreach ($messages as $type => $message) { |
31
|
|
|
$I->amGoingTo("send a message of this type: {$type}"); |
32
|
|
|
|
33
|
|
|
$service->send($message); |
34
|
|
|
} |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
public function ensureDotStuffingHappensAfterQuotePrintableEncode(IntegrationTester $I) |
38
|
|
|
{ |
39
|
|
|
$text_body = <<<EOT |
40
|
|
|
Test mail 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890. |
41
|
|
|
More text. |
42
|
|
|
EOT; |
43
|
|
|
|
44
|
|
|
$service = new SMTPMailService( |
45
|
|
|
$I->createSocketConnector(), new NoAuthenticator(), "localhost" |
46
|
|
|
); |
47
|
|
|
|
48
|
|
|
$message = new Message( |
49
|
|
|
new Address("[email protected]", "Rasmus åh Schultz"), |
50
|
|
|
new Address("[email protected]"), |
51
|
|
|
"Hey, Rasmus! I like ÆØÅæøå!", |
52
|
|
|
$text_body, |
53
|
|
|
); |
54
|
|
|
|
55
|
|
|
$message->setDate("Thu, 15 Sep 2016 17:20:54 +0200"); |
56
|
|
|
|
57
|
|
|
$message->setSender(new Address("[email protected]")); |
58
|
|
|
|
59
|
|
|
// Throws \Kodus\Mail\SMTP\UnexpectedCodeException if dot stuffing is after encoding |
60
|
|
|
$service->send($message); |
61
|
|
|
} |
62
|
|
|
} |
63
|
|
|
|