musala/cmd/trello2mail/main.go

33 lines
759 B
Go
Raw Normal View History

2018-08-21 08:36:54 +00:00
package main
import (
2018-08-22 16:57:50 +00:00
"fmt"
// "gopkg.in/russross/blackfriday.v2"
// "github.com/davecgh/go-spew/spew"
2018-08-21 08:36:54 +00:00
)
func main() {
// Setup config
config := NewConfig()
2018-08-21 23:50:50 +00:00
config.ParseEnv()
2018-08-21 08:36:54 +00:00
// Get task list as markdown
trelloCtx := NewTrello(config.Trello.Token)
trelloBoard := trelloCtx.GetBoard(config.Trello.Url)
trelloMarkdown := trelloBoard.ExportToMarkdown()
2018-08-22 16:57:50 +00:00
trelloHtml := trelloBoard.ExportToHtml()
config.Email.Subject = fmt.Sprintf("Daily mail for %s", trelloBoard.Name)
2018-08-21 23:50:50 +00:00
// Create email enveloppe
email := NewEmail()
2018-08-22 16:57:50 +00:00
email.SetHeaders(config.Email)
email.SetBody(trelloHtml, trelloMarkdown)
2018-08-21 23:50:50 +00:00
// Connect and send email
transport := NewTransport(config.Smtp)
transport.Dial()
transport.Authenticate()
transport.Send(email)
2018-08-21 23:50:50 +00:00
transport.Quit()
2018-08-21 08:36:54 +00:00
}