You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.MD
+12-16Lines changed: 12 additions & 16 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,13 +5,7 @@ Currently supports the `/send` endpoint (v3.1).
5
5
6
6
## Overview
7
7
8
-
**MailjetKit** is a lightweight, type-safe Swift SDK for sending emails using Mailjet’s REST API.
9
-
It focuses on simplicity, correctness, and modern Swift features such as:
10
-
11
-
-`async/await`
12
-
-`Codable`-based request/response models
13
-
- Strong typing for messages, recipients, and attachments
14
-
- Fluent, immutable “with/adding” helpers for constructing messages
8
+
**MailjetKit** is a lightweight, type-safe Swift SDK for sending emails using Mailjet’s REST API.
15
9
16
10
This package is ideal for server-side Swift (e.g. Vapor, Hummingbird, SwiftNIO apps), command-line tools, or macOS/iOS utilities that need to send transactional or templated emails.
17
11
@@ -71,10 +65,11 @@ let message = Message(
71
65
textPart: "Hello there! This is a plain text email from MailjetKit."
72
66
)
73
67
74
-
do {
75
-
let response =tryawait mailjet.send(message: message)
76
-
print("Message sent: \(response.status)")
77
-
} catch {
68
+
let response =await mailjet.send(message: message)
69
+
switch response {
70
+
case .success(let value):
71
+
print("Message sent: \(value.status)")
72
+
case .failure(let error):
78
73
print("Error sending email: \(error)")
79
74
}
80
75
```
@@ -96,10 +91,11 @@ let htmlMessage = Message(
96
91
)
97
92
)
98
93
99
-
do {
100
-
let response =tryawait mailjet.send(message: htmlMessage)
101
-
print("✅ Sent successfully: \(response)")
102
-
} catch {
94
+
let response =await mailjet.send(message: htmlMessage)
95
+
switch response {
96
+
case .success(let value):
97
+
print("✅ Sent successfully: \(value)")
98
+
case .failure(let error):
103
99
print("❌ Failed: \(error)")
104
100
}
105
101
```
@@ -122,5 +118,5 @@ let templatedMessage = Message(
0 commit comments