This commit is contained in:
Atridad Lahiji
2023-05-18 20:04:55 -06:00
committed by Atridad Lahiji
parent 84591f3a2d
commit 3d719132f1
96 changed files with 3422 additions and 4793 deletions

31
lib/email.go Normal file
View File

@ -0,0 +1,31 @@
package lib
import (
"fmt"
"os"
"github.com/resendlabs/resend-go"
)
var client *resend.Client
// init function
func init() {
client = resend.NewClient(os.Getenv("RESEND_API_KEY"))
}
func SendEmail(to_email string, from_email string, from_name string, html string, subject string) {
params := &resend.SendEmailRequest{
From: from_name + "<" + from_email + ">",
To: []string{to_email},
Html: html,
Subject: subject,
}
sent, err := client.Emails.Send(params)
if err != nil {
fmt.Println(err.Error())
return
}
fmt.Println(sent.Id)
}