Install & Compatibility
Where this runs
No compatibility data collected yet for this library.
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
sendgrid
✓ github.com/sendgrid/sendgrid-go
Send an email using SendGrid
package main
import (
"fmt"
"github.com/sendgrid/sendgrid-go"
"github.com/sendgrid/sendgrid-go/helpers/mail"
)
func main() {
from := mail.NewEmail("Example", "from@example.com")
subject := "Hello"
to := mail.NewEmail("Recipient", "to@example.com")
plainTextContent := "Hello World"
htmlContent := "<strong>Hello World</strong>"
message := mail.NewSingleEmail(from, subject, to, plainTextContent, htmlContent)
client := sendgrid.NewSendClient("YOUR_API_KEY")
response, err := client.Send(message)
if err != nil {
fmt.Println(err)
} else {
fmt.Println(response.StatusCode)
}
}
Upgrade
Version history
3.16.1+incompatiblelatest on pkg.go.dev
Audit
Dependencies
No dependency data recorded yet.