This commit is contained in:
2024-01-17 12:02:03 -07:00
parent 161cc95538
commit f8ce4e3b48
43 changed files with 1614 additions and 21 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)
}