-
Notifications
You must be signed in to change notification settings - Fork 270
Expand file tree
/
Copy pathexample_test.go
More file actions
41 lines (32 loc) · 1.11 KB
/
example_test.go
File metadata and controls
41 lines (32 loc) · 1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package nylas_test
import (
"context"
"github.com/nikoksr/notify"
"github.com/nikoksr/notify/service/nylas"
)
func Example() {
// Create a Nylas service instance with your credentials.
// Note: In production, use environment variables or a secure config for credentials.
nylasService := nylas.New(
"your-api-key", // Nylas API key
"your-grant-id", // Grant ID for the email account
"[email protected]", // Sender email address
"Your Name", // Sender display name
)
// Add one or more recipient email addresses.
nylasService.AddReceivers("[email protected]", "[email protected]")
// Optional: Set the body format (default is HTML).
nylasService.BodyFormat(nylas.HTML)
// Optional: Use a different region (e.g., EU region).
// nylasService.WithBaseURL("https://api.eu.nylas.com")
// Create a notifier and add the Nylas service.
notifier := notify.New()
notifier.UseServices(nylasService)
// Send a notification.
_ = notifier.Send(
context.Background(),
"Welcome to Notify with Nylas!",
"<h1>Hello!</h1><p>This is an email notification sent via Nylas API v3.</p>",
)
// Output:
}