| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 | package emailimport (	"context"	"regexp"	"github.com/gravitl/netmaker/logic")type EmailSenderType stringvar client EmailSenderconst (	Smtp   EmailSenderType = "smtp"	Resend EmailSenderType = "resend")func Init() {	smtpSender := &SmtpSender{		SmtpHost:    logic.GetSmtpHost(),		SmtpPort:    logic.GetSmtpPort(),		SenderEmail: logic.GetSenderEmail(),		SendUser:    logic.GetSenderUser(),		SenderPass:  logic.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,}$`)	return emailRegex.MatchString(email)}
 |