From e432258b508eb5a9f54467b3021cebdb73d2121a Mon Sep 17 00:00:00 2001 From: Hadi Sharghi Date: Thu, 13 Jun 2024 16:00:23 +0330 Subject: [PATCH] update README.md --- README.md | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index f628059..c2ad24c 100644 --- a/README.md +++ b/README.md @@ -38,12 +38,35 @@ let resendClient = ResendClient(httpClient: httpClient, apiKey: "YOUR_API_KEY") You can send a single email by creating a `ResendEmail` object and get the email ID in return. Use it as followed: + ~~~~swift import Resend -let email = ResendEmail(...) +let email: ResendEmail = .init( + from: .init(email: "hadi@example.com", name: "Hadi"), + to: ["hadi@domain.com"], + subject: "running xctest", + replyTo: [ + "hadi@example.com", + "manager@example.com" + ], + text: "sending email from XCTest suit", + headers: [ + .init(name: "X-Entity-Ref-ID", value: "234H3-44"), + .init(name: "X-Entity-Dep-ID", value: "SALE-03"), + ], + attachments: [ + .init(content: .init(data: .init(contentsOf: .init(filePath: "path/to/a/file"))), filename: "sales.xlsx") + ], + tags: [ + .init(name: "priority", value: "medium"), + .init(name: "department", value: "sales") + ] +) + let id = try await resendClient.emails.send(email) ~~~~ +`ResendEmail` supports both `text` and `html` content. You can send batch emails by creating a `ResendBatchEmail` object and send multiple emails at once.