From 03d109ff8b8ae47189878289b5e97193df2ea44e Mon Sep 17 00:00:00 2001 From: Dries De Peuter Date: Wed, 8 Dec 2021 14:41:27 +0100 Subject: [PATCH] feat: Add support for ignoring certs --- config.go | 1 + smtp.go | 10 ++++++++-- smtprelay.ini | 3 +++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/config.go b/config.go index 3d32766..99e0a4d 100644 --- a/config.go +++ b/config.go @@ -36,6 +36,7 @@ var ( allowedUsers = flag.String("allowed_users", "", "Path to file with valid users/passwords") command = flag.String("command", "", "Path to pipe command") remoteHost = flag.String("remote_host", "", "Outgoing SMTP server") + remoteSkipVerify = flag.Bool("remote_skip_verify", false, "Ignore invalid remote certificates") remoteUser = flag.String("remote_user", "", "Username for authentication on outgoing SMTP server") remotePass = flag.String("remote_pass", "", "Password for authentication on outgoing SMTP server") remoteAuthStr = flag.String("remote_auth", "none", "Auth method on outgoing SMTP server (none, plain, login)") diff --git a/smtp.go b/smtp.go index a37d90c..a32f286 100644 --- a/smtp.go +++ b/smtp.go @@ -337,7 +337,10 @@ func SendMail(addr string, a smtp.Auth, from string, to []string, msg []byte) er } var c *Client if port == "465" || port == "smtps" { - config := &tls.Config{ServerName: host} + config := &tls.Config{ + ServerName: host, + InsecureSkipVerify: *remoteSkipVerify, + } conn, err := tls.Dial("tcp", addr, config) if err != nil { return err @@ -360,7 +363,10 @@ func SendMail(addr string, a smtp.Auth, from string, to []string, msg []byte) er return err } if ok, _ := c.Extension("STARTTLS"); ok { - config := &tls.Config{ServerName: c.serverName} + config := &tls.Config{ + ServerName: c.serverName, + InsecureSkipVerify: *remoteSkipVerify, + } if testHookStartTLS != nil { testHookStartTLS(config) } diff --git a/smtprelay.ini b/smtprelay.ini index 5fb682b..28b7194 100644 --- a/smtprelay.ini +++ b/smtprelay.ini @@ -68,6 +68,9 @@ ; Mailjet.com ;remote_host = in-v3.mailjet.com:587 +; Ignore remote host certificates +;remote_skip_verify = false + ; Authentication credentials on outgoing SMTP server ;remote_user = ;remote_pass =