Created
October 12, 2022 19:35
-
-
Save mainawycliffe/d9ef5dfa4c64170a0531971544853191 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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