Change attachment type.

This commit is contained in:
Greg 2020-08-29 17:37:17 -04:00
parent 804bfed173
commit d66a96ba5e
1 changed files with 2 additions and 7 deletions

View File

@ -3,7 +3,6 @@ package main
import (
"bufio"
"bytes"
"encoding/base64"
"fmt"
"io"
"io/ioutil"
@ -130,11 +129,6 @@ func fetch() {
if err != nil {
log.Fatal("Error opening Rplot001.svg: ", err)
}
data, err := ioutil.ReadAll(f)
if err != nil {
log.Fatal("Cannot read Rplot001.svg: ", err)
}
data64 := base64.StdEncoding.EncodeToString(data)
defer f.Close()
for _, r := range conf.Recipients {
email := mailyak.New(fmt.Sprintf("%s:%d", conf.MailHost, conf.MailPort),
@ -144,7 +138,8 @@ func fetch() {
msg := "Covid dashboard update for " + time.Now().Format("Monday, January 2 2006")
email.Subject(msg)
email.Plain().Set(msg)
email.HTML().Set(`<html><body><img src="data:image/svg+xml;base64,`+data64+`"/></body></html>`)
email.HTML().Set(`<html><body><img src="dashboard.svg"/></body></html>`)
email.AttachInlineWithMimeType("dashboard.svg", f, "image/svg+xml")
err = email.Send()
if err != nil {
log.Print("Error sending email: ", err)