Change attachment type.

This commit is contained in:
Greg 2020-08-29 17:37:17 -04:00
parent 804bfed173
commit d66a96ba5e

View File

@ -3,7 +3,6 @@ package main
import ( import (
"bufio" "bufio"
"bytes" "bytes"
"encoding/base64"
"fmt" "fmt"
"io" "io"
"io/ioutil" "io/ioutil"
@ -130,11 +129,6 @@ func fetch() {
if err != nil { if err != nil {
log.Fatal("Error opening Rplot001.svg: ", err) 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() defer f.Close()
for _, r := range conf.Recipients { for _, r := range conf.Recipients {
email := mailyak.New(fmt.Sprintf("%s:%d", conf.MailHost, conf.MailPort), 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") msg := "Covid dashboard update for " + time.Now().Format("Monday, January 2 2006")
email.Subject(msg) email.Subject(msg)
email.Plain().Set(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() err = email.Send()
if err != nil { if err != nil {
log.Print("Error sending email: ", err) log.Print("Error sending email: ", err)