Skip to content

Simple client implementation for sending emails with file attachments

License

Notifications You must be signed in to change notification settings

stvoidit/gosmtp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

gosmtp

Usage example

func main() {
    client := gosmtp.NewSender(
        "admin1",
        "sosecretpassword",
        "admin1@example.com",
        "smtp.example.com:465")
    var recipients = [][]string{
        {"user1@example.com", "user2@example.com"},
        {"user3@example.com", "user4@example.com"},
    }
    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

About

Simple client implementation for sending emails with file attachments

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages