| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 | package emailimport (	"context"	"regexp"	"github.com/gravitl/netmaker/servercfg")type EmailSenderType stringvar client EmailSenderconst (	Smtp   EmailSenderType = "smtp"	Resend EmailSenderType = "resend")func init() {	smtpSender := &SmtpSender{		SmtpHost:    servercfg.GetSmtpHost(),		SmtpPort:    servercfg.GetSmtpPort(),		SenderEmail: servercfg.GetSenderEmail(),		SendUser:    servercfg.GetSenderUser(),		SenderPass:  servercfg.GetEmaiSenderPassword(),	}	if smtpSender.SendUser == "" {		smtpSender.SendUser = smtpSender.SenderEmail	}	client = smtpSender}// EmailSender - an interface for sending emails based on notifications and mail templatestype EmailSender interface {	// SendEmail - sends an email based on a context, notification and mail template	SendEmail(ctx context.Context, notification Notification, email Mail) error}type Mail interface {	GetBody(info Notification) string	GetSubject(info Notification) string}// Notification - struct for notification detailstype Notification struct {	RecipientMail string	RecipientName string	ProductName   string}func GetClient() (e EmailSender) {	return client}func IsValid(email string) bool {	emailRegex := regexp.MustCompile(`^[a-z0-9._%+\-]+@[a-z0-9.\-]+\.[a-z]{2,4}$`)	return emailRegex.MatchString(email)}
 |