-
Notifications
You must be signed in to change notification settings - Fork 260
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: update readme and upgrade guide
- Loading branch information
1 parent
c4de9e0
commit f298f3d
Showing
4 changed files
with
59 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -89,6 +89,49 @@ source ./sendgrid.env | |
|
||
The following is the minimum needed code to send an email with the [/mail/send Helper](helpers/mail) ([here](examples/helpers/mail/example.go#L32) is a full example): | ||
|
||
### Using Autogenerated Code | ||
```go | ||
package main | ||
|
||
import ( | ||
"encoding/json" | ||
"fmt" | ||
"github.com/sendgrid/sendgrid-go" | ||
MailV3 "github.com/sendgrid/sendgrid-go/rest/api/v3/mail" | ||
"net/http" | ||
"os" | ||
) | ||
|
||
func main() { | ||
client := sendgrid.NewRestClientWithParams(sendgrid.ClientParams{ | ||
ApiKey: os.Getenv("SENDGRID_API_KEY"), | ||
}) | ||
name := "John Doe" | ||
subject := "Sending with Twilio SendGrid is Fun" | ||
mailTo := &MailV3.MailTo{Email: "[email protected]"} | ||
to := []MailV3.MailTo{*mailTo} | ||
sendMailRequest := MailV3.SendMailRequest{ | ||
From: MailV3.MailFrom{Name: &name, Email: VERIFIED_EMAIL}, | ||
ReplyTo: mailTo, | ||
Subject: &subject, | ||
Personalizations: []MailV3.SendMailRequestPersonalizationsInner{{To: to}}, | ||
Content: &[]MailV3.SendMailRequestContentInner{{Type: "text/plain", Value: "Abc"}}, | ||
} | ||
sendMailParam := &MailV3.SendMailParam{SendMailRequest: &sendMailRequest} | ||
resp, err := client.MailV3.SendMail(sendMailParam) | ||
if err != nil { | ||
fmt.Println("Error sending mail: " + err.Error()) | ||
} else { | ||
response, _ := json.Marshal(resp) | ||
var ps http.Response | ||
json.Unmarshal(response, &ps) | ||
fmt.Println(ps.StatusCode) | ||
fmt.Println(ps.Body) | ||
fmt.Println(ps.Header) | ||
} | ||
} | ||
``` | ||
|
||
### With Mail Helper Class | ||
|
||
```go | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# Upgrade Guide | ||
|
||
_`MAJOR` version bumps will have upgrade notes posted here._ | ||
|
||
[2024-10-04] 3.x.x to 4.x.x-rc.x | ||
-------------------------------- | ||
### Overview | ||
|
||
#### Sendgrid Go Helper Library's version 4.0.0-rc.x is now available. | ||
|
||
Behind the scenes Go Helper is now auto-generated via OpenAPI with this release. This enables us to rapidly add new features and enhance consistency across versions and languages. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters