From 5d1774996f5c22a81903b5ae5f4c658dd45ed31f Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 13 Feb 2015 18:32:28 -0600 Subject: [PATCH] Allowing subject template values. Fixes #6 --- worker/worker.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/worker/worker.go b/worker/worker.go index 50120aba..1efcfa0a 100644 --- a/worker/worker.go +++ b/worker/worker.go @@ -49,6 +49,7 @@ func processCampaign(c *models.Campaign) { } for _, t := range c.Results { // Parse the templates + var subj_buff bytes.Buffer var html_buff bytes.Buffer var text_buff bytes.Buffer tmpl, err := template.New("html_template").Parse(c.Template.HTML) @@ -69,6 +70,15 @@ func processCampaign(c *models.Campaign) { Logger.Println(err) } e.Text = text_buff.Bytes() + tmpl, err = template.New("text_template").Parse(c.Template.Subject) + if err != nil { + Logger.Println(err) + } + err = tmpl.Execute(&subj_buff, t) + if err != nil { + Logger.Println(err) + } + e.Subject = string(subj_buff.Bytes()) Logger.Println("Creating email using template") e.To = []string{t.Email} err = e.Send(c.SMTP.Host, auth)