add go community package

This commit is contained in:
KMKoushik
2025-03-23 18:25:03 +11:00
parent eb1f8e4fe6
commit efe36248a6
4 changed files with 132 additions and 12 deletions

View File

@@ -0,0 +1,106 @@
---
title: Go
description: "The Unsend Go package lets you interact with the Unsend API to send and manage emails as well as domains. This is a quick guide on using the package to send emails and retrieve email information."
icon: golang
---
<Warning>
This is a community-maintained package and not maintained by the Unsend.
</Warning>
**Shout out to [QGeeDev](https://bsky.app/profile/qgdev.co.uk) for maintaining this package.**
## Installation
To install the Unsend package, you can use go get:
```bash
go get github.com/unsend/unsend-go
```
## Related Links
Github Repository: [Github](https://github.com/QGeeDev/unsend-go)
## Usage
Below is an example of how to use the Unsend package to send an email and retrieve email information.
### Environment Variables
```bash
export UNSEND_API_KEY="your-api-key"
export UNSEND_API_URL="https://app.unsend.dev" # or your self-hosted URL
```
### Initialize
```go
client, err := unsend.NewClient()
```
### Sending Emails
To send an email you will need to define the payload. After definition, you can use the `.SendEmail` method to send emails with the payload as a parameter.
```go
func main() {
godotenv.Load()
client, err := unsend.NewClient()
if err != nil {
fmt.Printf("[ERROR] - %s\n", err.Error())
os.Exit(1)
}
request := &unsend.SendEmailRequest{
To: []string{"youremail@gmail.com"},
From: "hello@yourdomain.com",
Subject: "Unsend test email",
Text: "hello,\n\nUnsend is the best open source sending platform",
Html: "<p>hello,</p><p>Unsend is the best open source sending platform</p><p>check out <a href='https://unsend.dev'>unsend.dev</a></p>",
}
response, err := client.Emails.SendEmail(context.Background(), *request)
if err != nil {
fmt.Printf("[ERROR] - %s\n", err.Error())
os.Exit(1)
}
fmt.Printf("[SUCCESS] - %s\n", response.EmailId)
}
```
### Retrieve Emails using the id
The email will be retrieved using the ID you get after sending the mail.
```go
func main() {
godotenv.Load()
client, err := unsend.NewClient()
getEmailRequest := unsend.GetEmailRequest{
EmailId: "your-email-id",
}
email, err := client.Emails.GetEmail(context.Background(), getEmailRequest)
if err != nil {
fmt.Printf("[ERROR] - %s\n", err.Error())
os.Exit(1)
}
fmt.Printf("[SUCCESS] - %s\n", email.Id)
}
```
### More
Checkout more examples in the [Github Repository](https://github.com/QGeeDev/unsend-go/tree/main/examples).
It handles `emails`, `domains` & `contacts` APIs.

View File

@@ -4,7 +4,14 @@ description: "The Unsend Python package lets you interact with the Unsend API to
icon: python
---
<Warning>
This is a community-maintained package and not maintained by the Unsend.
</Warning>
**Shout out to [harshsbhat](https://x.com/HarshBhatX) for maintaining this package.**
## Installation
To install the Unsend package, you can use pip:
```bash
@@ -12,15 +19,19 @@ pip install unsendcommunity
```
## Related Links
Github Repository: [Github](https://github.com/harshsbhat/unsend_community.git)
PyPI package: [PyPi](https://pypi.org/project/UnsendCommunity/)
## Usage
Below is an example of how to use the Unsend package to send an email and retrieve email information.
### Initialize
Change the URL accordingly if you are using self self-hosted version of Unsend. The default URL will be https://app.unsend.dev.
```python
from unsendcommunity import Unsend
@@ -32,7 +43,8 @@ client = Unsend(key=api_key, url='https://app.unsend.dev')
```
### Sending Emails
To send an email you will need to define the payload. After definition, you can use the ```.send_emails``` method to send emails with the payload as a parameter.
To send an email you will need to define the payload. After definition, you can use the `.send_emails` method to send emails with the payload as a parameter.
```python
payload = {
@@ -47,16 +59,18 @@ payload = {
response = client.send_email(payload)
print("Send Email Response:", response)
```
### Retrieve Emails using the id
The email will be retrieved using the ID you get after sending the mail.
```python
email_id = 'email-id-from-unsend'
email_response = client.get_email(email_id)
print("Get Email Response:", email_response)
```
The sample response of ``get_email`` is shown below:
The sample response of `get_email` is shown below:
```bash
{
@@ -97,7 +111,7 @@ domain_response = client.get_domain()
print("Get Domain Response:", domain_response)
```
Sample response of the ``get_domain`` method
Sample response of the `get_domain` method
```bash
{
@@ -124,4 +138,3 @@ Sample response of the ``get_domain`` method
"error": null
}
```

View File

@@ -63,7 +63,8 @@
{
"group": "Community SDKs",
"pages": [
"community-sdk/python"
"community-sdk/python",
"community-sdk/go"
]
},
{

View File

@@ -2,4 +2,4 @@
/// <reference types="next/image-types/global" />
// NOTE: This file should not be edited
// see https://nextjs.org/docs/basic-features/typescript for more information.
// see https://nextjs.org/docs/app/building-your-application/configuring/typescript for more information.