Skip to content

Commit

Permalink
add NewClientStartTLSWithLocalName
Browse files Browse the repository at this point in the history
  • Loading branch information
yumusb committed Sep 24, 2024
1 parent 554908d commit 4420295
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
8 changes: 4 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ module email_router

go 1.20

require gopkg.in/yaml.v2 v2.4.0

require (
github.com/emersion/go-smtp v0.21.3
gopkg.in/yaml.v2 v2.4.0
github.com/jhillyerd/enmime v1.3.0
github.com/yumusb/go-smtp v0.0.0-20240924122305-f5451c7fb690
)

require github.com/jhillyerd/enmime v1.3.0

require (
github.com/cention-sany/utf7 v0.0.0-20170124080048-26cad61bd60a // indirect
github.com/emersion/go-sasl v0.0.0-20200509203442-7bfe0ed36a21 // indirect
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ github.com/cention-sany/utf7 v0.0.0-20170124080048-26cad61bd60a/go.mod h1:2GxOXO
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/emersion/go-sasl v0.0.0-20200509203442-7bfe0ed36a21 h1:OJyUGMJTzHTd1XQp98QTaHernxMYzRaOasRir9hUlFQ=
github.com/emersion/go-sasl v0.0.0-20200509203442-7bfe0ed36a21/go.mod h1:iL2twTeMvZnrg54ZoPDNfJaJaqy0xIQFuBdrLsmspwQ=
github.com/emersion/go-smtp v0.21.3 h1:7uVwagE8iPYE48WhNsng3RRpCUpFvNl39JGNSIyGVMY=
github.com/emersion/go-smtp v0.21.3/go.mod h1:qm27SGYgoIPRot6ubfQ/GpiPy/g3PaZAVRxiO/sDUgQ=
github.com/go-test/deep v1.1.0 h1:WOcxcdHcvdgThNXjw0t76K42FXTU7HpNQWHpA2HHNlg=
github.com/gogs/chardet v0.0.0-20211120154057-b7413eaefb8f h1:3BSP1Tbs2djlpprl7wCLuiqMaUh5SJkkzI2gDs+FgLs=
github.com/gogs/chardet v0.0.0-20211120154057-b7413eaefb8f/go.mod h1:Pcatq5tYkCW2Q6yrR2VRHlbHpZ/R4/7qyL1TCF7vl14=
Expand All @@ -26,6 +24,8 @@ github.com/rivo/uniseg v0.4.4/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUc
github.com/ssor/bom v0.0.0-20170718123548-6386211fdfcf h1:pvbZ0lM0XWPBqUKqFU8cmavspvIl9nulOYwdy6IFRRo=
github.com/ssor/bom v0.0.0-20170718123548-6386211fdfcf/go.mod h1:RJID2RhlZKId02nZ62WenDCkgHFerpIOmW0iT7GKmXM=
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
github.com/yumusb/go-smtp v0.0.0-20240924122305-f5451c7fb690 h1:dqvLbl5VgcEXldLU2fDR9nRnfvP21eDzBDyS/kDLjH0=
github.com/yumusb/go-smtp v0.0.0-20240924122305-f5451c7fb690/go.mod h1:6H9N8q5t/2FIrI4cLbenXY+ecPmEn2BOVK5JTOhHWZ8=
golang.org/x/net v0.23.0 h1:7EYJ93RZ9vYSZAIb2x3lnuvqO5zneoD6IvWjuhfxjTs=
golang.org/x/net v0.23.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg=
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
Expand Down
7 changes: 5 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ import (
"strings"
"time"

"github.com/emersion/go-smtp"
"github.com/jhillyerd/enmime"
"github.com/yumusb/go-smtp"
"gopkg.in/yaml.v2"
)

Expand Down Expand Up @@ -299,7 +299,7 @@ func forwardEmailToTargetAddress(emailData []byte, formattedSender string, targe
tlsConfig := &tls.Config{
ServerName: smtpServer,
}
client, err := smtp.NewClientStartTLS(conn, tlsConfig)
client, err := smtp.NewClientStartTLSWithLocalName(conn, tlsConfig, GetEnv("MXDOMAIN", "localhost"))
if err != nil {
log.Printf("Failed to init StartTlS,%v", err)
return
Expand Down Expand Up @@ -389,6 +389,9 @@ func sendToTelegramBot(message string) {
}
defer resp.Body.Close()
log.Printf("Message sent to Telegram bot. Response: %s", resp.Status)
if resp.StatusCode != 200 {
log.Println(resp.Body)
}
}
func removeEmailHeaders(emailData []byte) ([]byte, error) {
msg, err := mail.ReadMessage(bytes.NewReader(emailData))
Expand Down

0 comments on commit 4420295

Please sign in to comment.