https://github.com/mailpace/gomailpace
A Go package for interacting with the MailPace API for sending emails.
https://github.com/mailpace/gomailpace
Last synced: about 1 year ago
JSON representation
A Go package for interacting with the MailPace API for sending emails.
- Host: GitHub
- URL: https://github.com/mailpace/gomailpace
- Owner: mailpace
- License: mit
- Created: 2024-01-04T21:21:36.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-01-17T14:49:26.000Z (over 2 years ago)
- Last Synced: 2025-02-12T04:59:01.257Z (over 1 year ago)
- Language: Go
- Size: 11.7 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# GoMailpace
[](https://pkg.go.dev/github.com/mailpace/gomailpace)
[](http://goreportcard.com/report/mailpace/gomailpace)
[](https://circleci.com/gh/mailpace/gomailpace)
[](https://codecov.io/gh/mailpace/gomailpace)
[](https://opensource.org/licenses/MIT)
[](https://golang.org/doc/go-get-installation)
[](https://github.com/mailpace/gomailpace/releases)
This Go package provides a client for interacting with the MailPace API for sending emails.
## Installation
To use this package in your Go project, you can import it using the following:
```go
import "github.com/mailpace/gomailpace"
import "context"
```
## Usage
### Creating a GoMailpace Client
```go
emailClient := gomailpace.NewClient("MAILPACE_TOKEN")
```
Replace "MAILPACE_TOKEN" with your actual MailPace API token.
### Sending an Email
```go
emailPayload := gomailpace.Payload{
From: "service@example.com",
To: "user@example.com",
Subject: "MailPace Rocks!",
TextBody: "MailPace is the best transactional email provider out there",
}
ctx := context.Background() // You can use context to handle request cancellation, deadlines etc.
err := emailClient.Send(ctx, emailPayload)
if err != nil {
// handle err
}
```
### Additional Options
You can include various options such as HTML body, CC, BCC, attachments, tags, etc. as specified in the MailPace API documentation: https://docs.mailpace.com/reference/send
```go
emailPayload := gomailpace.Payload{
From: "service@example.com",
To: "user@example.com",
Subject: "MailPace Rocks!",
HTMLBody: "
Content
",
CC: "cc@example.com",
Attachments: []gomailpace.Attachment{
{
Name: "attachment.jpg",
Content: "base64_encoded_string_here",
ContentType: "image/jpeg",
},
},
Tags: []string{"password reset", "welcome"},
}
```
## Running Tests
To run the unit tests for this package, use the following command:
```bash
go test
```
## Contributions
Feel free to contribute to this project by opening issues or submitting pull requests.
## License
This project is licensed under the MIT License - see the LICENSE file for details