Skip to contentSkip to navigationSkip to topbar
On this page

v2 API Go Code Example


(warning)

This documentation is for the SendGrid Web API v2

We will deprecate this version on February 10, 2025. To access all the latest features and upcoming developments, please see our v3 API. For assistance with transitioning, refer to our migration guide.

(information)
(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
1
// using SendGrid's Go Library
2
// https://github.com/sendgrid/sendgrid-go
3
package main
4
5
import (
6
"github.com/sendgrid/sendgrid-go"
7
)
8
9
func main() {
10
sg := sendgrid.NewSendGridClientWithApiKey("SENDGRID_APIKEY")
11
12
message := sendgrid.NewMail()
13
message.AddTo("test@sendgrid.com")
14
message.SetFrom("you@youremail.com")
15
message.SetSubject("Sending with SendGrid is Fun")
16
message.SetHTML("and easy to do anywhere, even with Go")
17
18
sg.Send(message)
19
}

Need some help?

Terms of service

Copyright © 2024 Twilio Inc.