func main() {
client := gosmtp.NewSender(
"admin1",
"sosecretpassword",
"[email protected]",
"smtp.example.com:465")
var recipients = [][]string{
{"[email protected]", "[email protected]"},
{"[email protected]", "[email protected]"},
}
var files = []string{
"file1.jpeg",
"file2.mp3",
}
for _, recs := range recipients {
var msg = gosmtp.NewMessage().
SetTO(recs...).
SetSubject("hello world").
SetText("something text").
AddAttaches(files...)
if err := client.SendMessage(msg); err != nil {
log.Fatalln(err)
}
}
}
Works with mail services:
- mail.yandex.ru
- e.mail.ru
- gmail.com
TODO:
- STARTTLS may be not worked. On outlook (smtp.office365.com:587) not work