Skip to contentSkip to navigationSkip to topbar
Rate this page:
On this page

v2 API Go Code Example


(information)

Info

We recommend using SendGrid Go, our client library, available on GitHub(link takes you to an external page), with full documentation.

(information)

Info

The library does not officially support the V2 API, but you can use V2 with an older version of the library. For more information, see Continue Using V2 in Go(link takes you to an external page).


Using SendGrid's Go Library

using-sendgrids-go-library page anchor

_19
// using SendGrid's Go Library
_19
// https://github.com/sendgrid/sendgrid-go
_19
package main
_19
_19
import (
_19
"github.com/sendgrid/sendgrid-go"
_19
)
_19
_19
func main() {
_19
sg := sendgrid.NewSendGridClientWithApiKey("SENDGRID_APIKEY")
_19
_19
message := sendgrid.NewMail()
_19
message.AddTo("test@sendgrid.com")
_19
message.SetFrom("you@youremail.com")
_19
message.SetSubject("Sending with SendGrid is Fun")
_19
message.SetHTML("and easy to do anywhere, even with Go")
_19
_19
sg.Send(message)
_19
}


Rate this page: