gosim
Gosim(Go + Simple + Mailer)
Dead simple email client for Go
Get started
Add the package
go get github.com/michaelgrigoryan25/gosim
Then, just include it in your code like this
import (
"github.com/michaelgrigoryan25/gosim"
)
Quickstart
To send emails with Gosim you will need several things:
- SMTP host
- SMTP port
- SMTP username
- SMTP password
Client
Struct Client
is the SMTP client that is used to send the emails
type Client struct {
Host string
User string
Pass string
Port string
}
Message
Sturct Message
provides a really easy way to construct an email
type Message struct {
Subject string
Message string
From string
Type ContentType
To []string
}
Content Type
Enum ContentType
is used to specify the Content-Type
header of the email
type ContentType string
const (
Html ContentType = "HTML"
Text ContentType = "TEXT"
)
Examples
Here's a complete example to get you started with Gosim
package main
import (
"github.com/michaelgrigoryan25/gosim"
)
func main() {
client := gosim.Client{
Port: "smtp-port",
Host: "smtp.domain.com",
User: "[email protected]",
Pass: "some-random-password",
}
message := gosim.Message{
Subject: "Hello World",
To: []string{
"[email protected]",
"[email protected]",
},
From: "[email protected]",
Message: "This is my message sent from Gosim",
}
err := client.SendFunc(&message)
if err != nil {
fmt.Println("Failed to send the email")
}
fmt.Println("Sent the email successfully")
}
Contributions
This project is open to any suggestions, contributions, issues and pull-requests!