Skip to content

Instantly share code, notes, and snippets.

@mainawycliffe
Created October 12, 2022 19:35
Show Gist options
  • Save mainawycliffe/d9ef5dfa4c64170a0531971544853191 to your computer and use it in GitHub Desktop.
Save mainawycliffe/d9ef5dfa4c64170a0531971544853191 to your computer and use it in GitHub Desktop.
type Mail struct {
host string
port string
from string
password string
username string
}
func (m *Mail) Send(toEmails []string, subject string, body string) error {
address := fmt.Sprintf("%s:%s", m.host, m.port)
message := []byte(subject + body)
auth := smtp.PlainAuth("", m.username, m.password, m.host)
err := smtp.SendMail(address, auth, m.from, toEmails, message)
return err
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment