2018-08-21 08:36:54 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2018-08-22 16:57:50 +00:00
|
|
|
"fmt"
|
2018-08-21 08:36:54 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
// Setup config
|
|
|
|
config := NewConfig()
|
2018-11-23 10:46:12 +00:00
|
|
|
config.Parse()
|
2018-08-21 08:36:54 +00:00
|
|
|
|
2018-08-21 17:21:46 +00:00
|
|
|
// Get task list as markdown
|
2018-11-23 10:46:12 +00:00
|
|
|
trelloCtx := NewTrello(config.TrelloToken)
|
2018-11-23 12:22:03 +00:00
|
|
|
for _, trelloBoard := range trelloCtx.GetBoards() {
|
|
|
|
if !trelloBoard.Starred || trelloBoard.Closed {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
fmt.Printf("Loading board %s\n", trelloBoard.Name)
|
|
|
|
|
|
|
|
// trelloBoard := trelloCtx.GetBoard(config.TrelloUrl)
|
|
|
|
trelloMarkdown := trelloBoard.ExportToMarkdown()
|
|
|
|
trelloHtml := trelloBoard.ExportToHtml()
|
|
|
|
config.EmailSubject = fmt.Sprintf("Daily mail for %s", trelloBoard.Name)
|
|
|
|
|
|
|
|
// Create email enveloppe
|
|
|
|
email := NewEmail()
|
|
|
|
email.SetHeaders(EmailConfig{
|
|
|
|
From: config.EmailFrom,
|
|
|
|
To: config.EmailTo,
|
|
|
|
Subject: config.EmailSubject,
|
|
|
|
})
|
|
|
|
email.SetBody(trelloHtml, trelloMarkdown)
|
|
|
|
|
|
|
|
// Connect and send email
|
|
|
|
transport := NewTransport(SmtpConfig{
|
|
|
|
Hostname: config.SmtpHostname,
|
|
|
|
Port: config.SmtpPort,
|
|
|
|
Username: config.SmtpUsername,
|
|
|
|
Password: config.SmtpPassword,
|
|
|
|
AuthType: config.SmtpAuthType,
|
|
|
|
SecurityType: config.SmtpSecurityType,
|
|
|
|
})
|
|
|
|
|
|
|
|
transport.Dial()
|
|
|
|
transport.Authenticate()
|
|
|
|
transport.Send(email)
|
|
|
|
transport.Quit()
|
|
|
|
|
|
|
|
}
|
2018-08-21 08:36:54 +00:00
|
|
|
}
|