diff --git a/apps/docs/community-sdk/go.mdx b/apps/docs/community-sdk/go.mdx new file mode 100644 index 0000000..6ed31f7 --- /dev/null +++ b/apps/docs/community-sdk/go.mdx @@ -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 +--- + + + This is a community-maintained package and not maintained by the Unsend. + + +**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: "

hello,

Unsend is the best open source sending platform

check out unsend.dev

", + } + + 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. diff --git a/apps/docs/community-sdk/python.mdx b/apps/docs/community-sdk/python.mdx index 3c83442..b0be38a 100644 --- a/apps/docs/community-sdk/python.mdx +++ b/apps/docs/community-sdk/python.mdx @@ -4,23 +4,34 @@ description: "The Unsend Python package lets you interact with the Unsend API to icon: python --- + + This is a community-maintained package and not maintained by the Unsend. + + +**Shout out to [harshsbhat](https://x.com/HarshBhatX) for maintaining this package.** + ## Installation + To install the Unsend package, you can use pip: -```bash +```bash 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. + +### 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 { @@ -89,15 +103,15 @@ The sample response of ``get_email`` is shown below: ### Retrieve domain information -Retrieves domain information -Domains that are associated with this account will be displayed with their detailed information. +Retrieves domain information +Domains that are associated with this account will be displayed with their detailed information. ```python 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 } ``` - diff --git a/apps/docs/mint.json b/apps/docs/mint.json index f88743d..23f0dcc 100644 --- a/apps/docs/mint.json +++ b/apps/docs/mint.json @@ -63,7 +63,8 @@ { "group": "Community SDKs", "pages": [ - "community-sdk/python" + "community-sdk/python", + "community-sdk/go" ] }, { diff --git a/apps/web/next-env.d.ts b/apps/web/next-env.d.ts index 4f11a03..40c3d68 100644 --- a/apps/web/next-env.d.ts +++ b/apps/web/next-env.d.ts @@ -2,4 +2,4 @@ /// // 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.