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)
|
|
|
|
trelloBoard := trelloCtx.GetBoard(config.TrelloUrl)
|
2018-08-21 17:21:46 +00:00
|
|
|
trelloMarkdown := trelloBoard.ExportToMarkdown()
|
2018-08-22 16:57:50 +00:00
|
|
|
trelloHtml := trelloBoard.ExportToHtml()
|
2018-11-23 10:46:12 +00:00
|
|
|
config.EmailSubject = fmt.Sprintf("Daily mail for %s", trelloBoard.Name)
|
2018-08-21 17:21:46 +00:00
|
|
|
|
2018-08-21 23:50:50 +00:00
|
|
|
// Create email enveloppe
|
2018-08-21 17:21:46 +00:00
|
|
|
email := NewEmail()
|
2018-11-23 10:46:12 +00:00
|
|
|
email.SetHeaders(EmailConfig{
|
|
|
|
From: config.EmailFrom,
|
|
|
|
To: config.EmailTo,
|
|
|
|
Subject: config.EmailSubject,
|
|
|
|
})
|
2018-08-22 16:57:50 +00:00
|
|
|
email.SetBody(trelloHtml, trelloMarkdown)
|
2018-08-21 17:21:46 +00:00
|
|
|
|
2018-08-21 23:50:50 +00:00
|
|
|
// Connect and send email
|
2018-11-23 10:46:12 +00:00
|
|
|
transport := NewTransport(SmtpConfig{
|
|
|
|
Hostname: config.SmtpHostname,
|
|
|
|
Port: config.SmtpPort,
|
|
|
|
Username: config.SmtpUsername,
|
|
|
|
Password: config.SmtpPassword,
|
|
|
|
AuthType: config.SmtpAuthType,
|
|
|
|
SecurityType: config.SmtpSecurityType,
|
|
|
|
})
|
|
|
|
|
2018-08-21 23:50:50 +00:00
|
|
|
transport.Dial()
|
|
|
|
transport.Authenticate()
|
2018-08-21 17:21:46 +00:00
|
|
|
transport.Send(email)
|
2018-08-21 23:50:50 +00:00
|
|
|
transport.Quit()
|
2018-08-21 08:36:54 +00:00
|
|
|
}
|