Go Ask Question で添付ファイル付きのメールを送信する方法

Go Ask Question で添付ファイル付きのメールを送信する方法

私はこのライブラリを見つけ、空の電子メールで添付ファイルを送信することはできましたが、テキストと添付ファイルを結合することはできませんでした。

https://github.com/sloonz/go-mime-message

どうすればそれができるのでしょうか?

ベストアンサー1

結局、自分で実装しました:https://github.com/scorredoira/email

使い方は非常に簡単です:

m := email.NewMessage("Hi", "this is the body")
m.From = "[email protected]"
m.To = []string{"[email protected]"}

err := m.Attach("picture.png")
if err != nil {
    log.Println(err)
}

err = email.Send("smtp.gmail.com:587", smtp.PlainAuth("", "user", "password", "smtp.gmail.com"), m)

おすすめ記事