https://github.com/circa10a/go-mailform
A small library to send physical mail from your Go applications using https://mailform.io
https://github.com/circa10a/go-mailform
go go-library golang hacktoberfest mail
Last synced: 10 months ago
JSON representation
A small library to send physical mail from your Go applications using https://mailform.io
- Host: GitHub
- URL: https://github.com/circa10a/go-mailform
- Owner: circa10a
- License: mit
- Created: 2022-10-09T20:23:58.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2023-01-17T14:25:02.000Z (over 3 years ago)
- Last Synced: 2025-01-10T22:53:22.135Z (over 1 year ago)
- Topics: go, go-library, golang, hacktoberfest, mail
- Language: Go
- Homepage:
- Size: 23.4 KB
- Stars: 5
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# go-mailform

[](https://pkg.go.dev/github.com/circa10a/go-mailform?tab=overview)
[](https://goreportcard.com/report/github.com/circa10a/go-mailform)
A small library to send physical mail from your Go applications using https://mailform.io
## Usage
First you will need an API Token from [mailform.io](https://mailform.io)
```bash
go get github.com/circa10a/go-mailform
```
```go
package main
import (
"fmt"
"os"
"github.com/circa10a/go-mailform"
)
func main() {
client, err := mailform.New(&mailform.Config{
Token: "MAILFORM_API_TOKEN",
})
if err != nil {
fmt.Println(err)
}
// Create order
// You can send a PDF file via local filesystem path or a URL.
// FilePath will take precedence over URL.
order, err := client.CreateOrder(mailform.OrderInput{
// Send local pdf
FilePath: "./sample.pdf",
// Or you can send the file via URL
URL: "http://s3.amazonaws.com/some-bucket/sample.pdf",
// Shipping service options:
// FEDEX_OVERNIGHT USPS_PRIORITY_EXPRESS USPS_PRIORITY USPS_CERTIFIED_PHYSICAL_RECEIPT USPS_CERTIFIED_RECEIPT USPS_CERTIFIED USPS_FIRST_CLASS USPS_STANDARD USPS_POSTCARD
Service: "USPS_PRIORITY",
ToName: "A Name",
ToAddress1: "Address 1",
ToCity: "Seattle",
ToState: "WA",
ToPostcode: "00000",
ToCountry: "US",
FromName: "My Name",
FromAddress1: "My Address 1",
FromCity: "Dallas",
FromState: "TX",
FromPostcode: "00000",
FromCountry: "US",
})
if err != nil {
fmt.Println(err)
os.Exit(1)
}
fmt.Println("Order ID", order.Data.ID)
// Get Order
orderDetails, err := client.GetOrder(order.Data.ID)
if err != nil {
fmt.Println(err)
os.Exit(1)
}
fmt.Println(orderDetails.Data)
}
```