Send mail only if text/html
Anirudh Oppiliappan x@icyphox.sh
Fri, 01 Oct 2021 15:52:48 +0530
1 files changed,
10 insertions(+),
10 deletions(-)
jump to
M
main.go
→
main.go
@@ -37,18 +37,18 @@ if err != nil {
log.Printf("reader fetch: %v\n", err) } - if resp.MIMEType != "text/html" { - err = mail.SendAttachment(resp, m.From, u) - if err != nil { - log.Printf("error sending attachment to: %s: %v\n", m.From, err) - } else { - log.Printf("sent attachment to %s: %s\n", m.From, resp.MIMEType) - } - break - } + // if resp.MIMEType != "text/html" { + // err = mail.SendAttachment(resp, m.From, u) + // if err != nil { + // log.Printf("error sending attachment to: %s: %v\n", m.From, err) + // } else { + // log.Printf("sent attachment to %s: %s\n", m.From, resp.MIMEType) + // } + // break + // } article, err := reader.Readable(resp.Body, parsedURL) - if err == nil { + if (err == nil) && (resp.MIMEType == "text/html") { err = mail.SendArticle(&article, m.From, true) if err != nil { log.Printf("error sending mail to: %s: %v\n", m.From, err)