all repos — navani @ 577dcf5c5509a950dfd2c4abd1c6bf2b39dd4dda

forlater's primary mail processing service

Better lynx args
Anirudh Oppiliappan x@icyphox.sh
Sun, 26 Sep 2021 10:22:32 +0530
commit

577dcf5c5509a950dfd2c4abd1c6bf2b39dd4dda

parent

9a42d124e49c986b4407539b547eca650dda03e1

3 files changed, 13 insertions(+), 2 deletions(-)

jump to
M go.modgo.mod

@@ -10,6 +10,6 @@ github.com/joegrasse/mail v1.0.0

github.com/joegrasse/mime v0.0.0-20151001172835-f543c4783e35 // indirect github.com/joho/godotenv v1.3.0 github.com/microcosm-cc/bluemonday v1.0.15 - golang.org/x/net v0.0.0-20210908191846-a5e095526f91 // indirect + golang.org/x/net v0.0.0-20210908191846-a5e095526f91 mvdan.cc/xurls/v2 v2.3.0 )
M mail/send.gomail/send.go

@@ -32,6 +32,9 @@ return err

} plainContent, err := reader.MakePlaintext(htmlContent) + if err != nil { + return fmt.Errorf("making plaintext: %w\n", err) + } email := mail.New() email.Encryption = mail.EncryptionTLS
M reader/plain.goreader/plain.go

@@ -1,12 +1,20 @@

package reader import ( + "fmt" "os/exec" "strings" ) func MakePlaintext(html []byte) ([]byte, error) { - args := []string{"-image_links", "-dump", "-stdin"} + fmt.Println(string(html)) + args := []string{ + "-dont_wrap_pre", + "-display_charset=UTF-8", + "-image_links", + "-dump", + "-stdin", + } cmd := exec.Command("lynx", args...) cmd.Stdin = strings.NewReader(string(html)) out, err := cmd.Output()