GoScrobble/internal/goscrobble/smtp.go
Daniel Mason fd615102a8
0.0.10
- Fixed looking up invalid profiles
- Added valid error handling to bad request && rate limiting
- Add Sendgrid library (Will add SMTP later)
- Complete password reset process
2021-04-02 01:56:08 +13:00

19 lines
514 B
Go

package goscrobble
import (
"os"
"github.com/sendgrid/sendgrid-go"
"github.com/sendgrid/sendgrid-go/helpers/mail"
)
func sendEmail(destName string, destEmail string, subject string, content string) error {
from := mail.NewEmail(os.Getenv("MAIL_FROM_NAME"), os.Getenv("MAIL_FROM_ADDRESS"))
to := mail.NewEmail(destName, destEmail)
message := mail.NewSingleEmail(from, subject, to, content, "")
client := sendgrid.NewSendClient(os.Getenv("SENDGRID_API_KEY"))
_, err := client.Send(message)
return err
}