@@ -38,15 +38,36 @@ final class SmtpTests: XCTestCase {
38
38
body: " This is email body. " )
39
39
40
40
let request = Request ( application: application, on: application. eventLoopGroup. next ( ) )
41
- try request. send ( email) { message in
41
+ try request. smtp . send ( email) { message in
42
42
print ( message)
43
43
} . flatMapThrowing { result in
44
44
XCTAssertTrue ( try result. get ( ) )
45
45
} . wait ( )
46
-
46
+
47
47
sleep ( 3 )
48
48
}
49
49
50
+ func testSendTextMessageViaApplication( ) throws {
51
+ let application = Application ( )
52
+ defer {
53
+ application. shutdown ( )
54
+ }
55
+
56
+ application. smtp. configuration = smtpConfiguration
57
+ let email = Email ( from
: EmailAddress ( address
: " [email protected] " , name
: " John Doe " ) ,
58
+ to
: [ EmailAddress ( address
: " [email protected] " , name
: " Ben Doe " ) ] ,
59
+ subject: " The subject (text) - \( timestamp) " ,
60
+ body: " This is email body. " )
61
+
62
+ try application. smtp. send ( email) { message in
63
+ print ( message)
64
+ } . flatMapThrowing { result in
65
+ XCTAssertTrue ( try result. get ( ) )
66
+ } . wait ( )
67
+
68
+ sleep ( 3 )
69
+ }
70
+
50
71
func testSendTextMessageWithoutNames( ) throws {
51
72
let application = Application ( )
52
73
defer {
@@ -60,7 +81,7 @@ final class SmtpTests: XCTestCase {
60
81
body: " This is email body. " )
61
82
62
83
let request = Request ( application: application, on: application. eventLoopGroup. next ( ) )
63
- try request. send ( email) { message in
84
+ try request. smtp . send ( email) { message in
64
85
print ( message)
65
86
} . flatMapThrowing { result in
66
87
XCTAssertTrue ( try result. get ( ) )
@@ -83,7 +104,7 @@ final class SmtpTests: XCTestCase {
83
104
isBodyHtml: true )
84
105
85
106
let request = Request ( application: application, on: application. eventLoopGroup. next ( ) )
86
- try request. send ( email) { message in
107
+ try request. smtp . send ( email) { message in
87
108
print ( message)
88
109
} . flatMapThrowing { result in
89
110
XCTAssertTrue ( try result. get ( ) )
@@ -108,7 +129,7 @@ final class SmtpTests: XCTestCase {
108
129
email. addAttachment ( Attachment ( name: " image.png " , contentType: " image/png " , data: Attachments . image ( ) ) )
109
130
110
131
let request = Request ( application: application, on: application. eventLoopGroup. next ( ) )
111
- try request. send ( email) { message in
132
+ try request. smtp . send ( email) { message in
112
133
print ( message)
113
134
} . flatMapThrowing { result in
114
135
XCTAssertTrue ( try result. get ( ) )
@@ -134,7 +155,7 @@ final class SmtpTests: XCTestCase {
134
155
email. addAttachment ( Attachment ( name: " image.png " , contentType: " image/png " , data: Attachments . image ( ) ) )
135
156
136
157
let request = Request ( application: application, on: application. eventLoopGroup. next ( ) )
137
- try request. send ( email) { message in
158
+ try request. smtp . send ( email) { message in
138
159
print ( message)
139
160
} . flatMapThrowing { result in
140
161
XCTAssertTrue ( try result. get ( ) )
@@ -159,7 +180,7 @@ final class SmtpTests: XCTestCase {
159
180
body: " This is email body. " )
160
181
161
182
let request = Request ( application: application, on: application. eventLoopGroup. next ( ) )
162
- try request. send ( email) { message in
183
+ try request. smtp . send ( email) { message in
163
184
print ( message)
164
185
} . flatMapThrowing { result in
165
186
XCTAssertTrue ( try result. get ( ) )
@@ -188,7 +209,7 @@ final class SmtpTests: XCTestCase {
188
209
body: " This is email body. " )
189
210
190
211
let request = Request ( application: application, on: application. eventLoopGroup. next ( ) )
191
- try request. send ( email) { message in
212
+ try request. smtp . send ( email) { message in
192
213
print ( message)
193
214
} . flatMapThrowing { result in
194
215
XCTAssertTrue ( try result. get ( ) )
@@ -211,7 +232,7 @@ final class SmtpTests: XCTestCase {
211
232
replyTo
: EmailAddress ( address
: " [email protected] " ) )
212
233
213
234
let request = Request ( application: application, on: application. eventLoopGroup. next ( ) )
214
- try request. send ( email) { message in
235
+ try request. smtp . send ( email) { message in
215
236
print ( message)
216
237
} . flatMapThrowing { result in
217
238
XCTAssertTrue ( try result. get ( ) )
@@ -236,7 +257,7 @@ final class SmtpTests: XCTestCase {
236
257
email. addAttachment ( Attachment ( name: " image.png " , contentType: " image/png " , data: Attachments . image ( ) ) )
237
258
238
259
let request = Request ( application: application, on: application. eventLoopGroup. next ( ) )
239
- try request. send ( email) { message in
260
+ try request. smtp . send ( email) { message in
240
261
print ( message)
241
262
} . flatMapThrowing { result in
242
263
XCTAssertTrue ( try result. get ( ) )
@@ -259,7 +280,7 @@ final class SmtpTests: XCTestCase {
259
280
email. addAttachment ( Attachment ( name: " image.png " , contentType: " image/png " , data: Attachments . image ( ) ) )
260
281
261
282
let request = Request ( application: application, on: application. eventLoopGroup. next ( ) )
262
- try request. send ( email) { message in
283
+ try request. smtp . send ( email) { message in
263
284
print ( message)
264
285
} . flatMapThrowing { result in
265
286
XCTAssertTrue ( try result. get ( ) )
0 commit comments