|
|
@@ -1,7 +1,6 @@
|
|
|
package email
|
|
|
|
|
|
import (
|
|
|
- "fmt"
|
|
|
"os"
|
|
|
|
|
|
"github.com/sendgrid/sendgrid-go"
|
|
|
@@ -11,6 +10,7 @@ import (
|
|
|
type SendgridClient struct {
|
|
|
APIKey string
|
|
|
PWResetTemplateID string
|
|
|
+ PWGHTemplateID string
|
|
|
VerifyEmailTemplateID string
|
|
|
ProjectInviteTemplateID string
|
|
|
SenderEmail string
|
|
|
@@ -48,6 +48,38 @@ func (client *SendgridClient) SendPWResetEmail(url, email string) error {
|
|
|
return err
|
|
|
}
|
|
|
|
|
|
+func (client *SendgridClient) SendGHPWEmail(url, email string) error {
|
|
|
+ request := sendgrid.GetRequest(os.Getenv("SENDGRID_API_KEY"), "/v3/mail/send", "https://api.sendgrid.com")
|
|
|
+ request.Method = "POST"
|
|
|
+
|
|
|
+ sgMail := &mail.SGMailV3{
|
|
|
+ Personalizations: []*mail.Personalization{
|
|
|
+ {
|
|
|
+ To: []*mail.Email{
|
|
|
+ {
|
|
|
+ Address: email,
|
|
|
+ },
|
|
|
+ },
|
|
|
+ DynamicTemplateData: map[string]interface{}{
|
|
|
+ "url": url,
|
|
|
+ "email": email,
|
|
|
+ },
|
|
|
+ },
|
|
|
+ },
|
|
|
+ From: &mail.Email{
|
|
|
+ Address: client.SenderEmail,
|
|
|
+ Name: "Porter",
|
|
|
+ },
|
|
|
+ TemplateID: client.PWGHTemplateID,
|
|
|
+ }
|
|
|
+
|
|
|
+ request.Body = mail.GetRequestBody(sgMail)
|
|
|
+
|
|
|
+ _, err := sendgrid.API(request)
|
|
|
+
|
|
|
+ return err
|
|
|
+}
|
|
|
+
|
|
|
func (client *SendgridClient) SendEmailVerification(url, email string) error {
|
|
|
request := sendgrid.GetRequest(os.Getenv("SENDGRID_API_KEY"), "/v3/mail/send", "https://api.sendgrid.com")
|
|
|
request.Method = "POST"
|
|
|
@@ -84,8 +116,6 @@ func (client *SendgridClient) SendProjectInviteEmail(url, project, projectOwnerE
|
|
|
request := sendgrid.GetRequest(os.Getenv("SENDGRID_API_KEY"), "/v3/mail/send", "https://api.sendgrid.com")
|
|
|
request.Method = "POST"
|
|
|
|
|
|
- fmt.Println("GOT HERE", url, project, projectOwnerEmail, email)
|
|
|
-
|
|
|
sgMail := &mail.SGMailV3{
|
|
|
Personalizations: []*mail.Personalization{
|
|
|
{
|