softplayer-backend/internal/helpers/email/email.go

23 lines
429 B
Go

package email
import (
"net/smtp"
)
type EmailConf struct {
From string
Password string
SmtpHost string
SmtpPort string
}
func (e *EmailConf) SendEmail(to string, message string) error {
messageByte := []byte(message)
auth := smtp.PlainAuth("", e.From, e.Password, e.SmtpHost)
if err := smtp.SendMail(e.SmtpHost+":"+e.SmtpPort, auth, e.From, []string{to}, messageByte); err != nil {
return err
}
return nil
}