This repository has been archived on 2025-08-09. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
web-app-template/utils/mail.go

16 lines
445 B
Go

package utils
import (
"fmt"
"net/smtp"
)
func SendMail(to string, subject string, message string) error {
auth := smtp.PlainAuth("", SmtpUser, SmtpPass, SmtpHost)
msg := fmt.Sprintf("From: %v <%v>\nTo: %v\nSubject: %v\nMIME-version: 1.0;\nContent-Type: text/html; charset=\"UTF-8\";\n\n%v", SmtpFromName, SmtpFromMail, to, subject, message)
return smtp.SendMail(SmtpHost+":"+SmtpPort, auth, SmtpFromMail, []string{to}, []byte(msg))
}