File tree 4 files changed +17
-3
lines changed
4 files changed +17
-3
lines changed Original file line number Diff line number Diff line change @@ -35,7 +35,7 @@ smtpbridge --version
35
35
36
36
## Config
37
37
38
- Config file is loaded from one of the following locations.
38
+ Config file is loaded from one of the following locations.
39
39
40
40
- ` config.yaml `
41
41
- ` config.yml `
Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ require (
11
11
github.com/emersion/go-smtp v0.16.0
12
12
github.com/gofiber/fiber/v2 v2.47.0
13
13
github.com/gofiber/template/html/v2 v2.0.4
14
+ github.com/jaytaylor/html2text v0.0.0-20200412013138-3577fbdbcff7
14
15
github.com/jhillyerd/enmime v1.0.0
15
16
github.com/labstack/gommon v0.4.0
16
17
github.com/rs/zerolog v1.29.1
@@ -29,7 +30,6 @@ require (
29
30
github.com/gofiber/utils v1.1.0 // indirect
30
31
github.com/gogs/chardet v0.0.0-20191104214054-4b6791f73a28 // indirect
31
32
github.com/google/uuid v1.3.0 // indirect
32
- github.com/jaytaylor/html2text v0.0.0-20200412013138-3577fbdbcff7 // indirect
33
33
github.com/jinzhu/inflection v1.0.0 // indirect
34
34
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 // indirect
35
35
github.com/klauspost/compress v1.16.3 // indirect
Original file line number Diff line number Diff line change 4
4
"time"
5
5
6
6
"github.com/ItsNotGoodName/smtpbridge/pkg/pagination"
7
+ "github.com/jaytaylor/html2text"
7
8
"github.com/samber/lo"
8
9
)
9
10
@@ -17,12 +18,21 @@ type CreateMessage struct {
17
18
}
18
19
19
20
func NewMessage (r CreateMessage ) * Message {
21
+ text := r .Text
22
+ if isHTML (r .Text ) {
23
+ var err error
24
+ text , err = html2text .FromString (r .Text )
25
+ if err != nil {
26
+ text = r .Text
27
+ }
28
+ }
29
+
20
30
return & Message {
21
31
From : r .From ,
22
32
To : lo .Uniq (r .To ),
23
33
CreatedAt : time .Now (),
24
34
Subject : r .Subject ,
25
- Text : r . Text ,
35
+ Text : text ,
26
36
HTML : r .HTML ,
27
37
Date : r .Date ,
28
38
}
Original file line number Diff line number Diff line change @@ -34,3 +34,7 @@ func fileExtension(name string, mimeT string) string {
34
34
}
35
35
return extension
36
36
}
37
+
38
+ func isHTML (maybeHTML string ) bool {
39
+ return strings .HasPrefix (maybeHTML , "<!DOCTYPE html>" )
40
+ }
You can’t perform that action at this time.
0 commit comments