about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorDrew DeVault <sir@cmpwn.com>2019-05-20 17:25:12 -0400
committerDrew DeVault <sir@cmpwn.com>2019-05-20 17:25:12 -0400
commitcc90cd21610e7c78bc2cd9b04840fa1266617e6f (patch)
treefa8265e80faf4ae6055d7137592bf315c87604f3
parent33f2d4f9ee132e979ad5f92284d87e6e2a56426d (diff)
downloadaerc-cc90cd21610e7c78bc2cd9b04840fa1266617e6f.tar.gz
Pass ServerName to tls.Config for SMTP
-rw-r--r--commands/compose/send.go14
1 files changed, 12 insertions, 2 deletions
diff --git a/commands/compose/send.go b/commands/compose/send.go
index 356b0c7..2c2e294 100644
--- a/commands/compose/send.go
+++ b/commands/compose/send.go
@@ -93,8 +93,11 @@ func SendMessage(aerc *widgets.Aerc, args []string) error {
 		switch scheme {
 		case "smtp":
 			host := uri.Host
+			serverName := uri.Host
 			if !strings.ContainsRune(host, ':') {
 				host = host + ":587" // Default to submission port
+			} else {
+				serverName = host[:strings.IndexRune(host, ':')]
 			}
 			conn, err = smtp.Dial(host)
 			if err != nil {
@@ -108,7 +111,9 @@ func SendMessage(aerc *widgets.Aerc, args []string) error {
 						"Add smtp-starttls=yes")
 					return 0, err
 				}
-				if err = conn.StartTLS(&tls.Config{}); err != nil {
+				if err = conn.StartTLS(&tls.Config{
+					ServerName: serverName,
+				}); err != nil {
 					return 0, err
 				}
 			} else {
@@ -121,10 +126,15 @@ func SendMessage(aerc *widgets.Aerc, args []string) error {
 			}
 		case "smtps":
 			host := uri.Host
+			serverName := uri.Host
 			if !strings.ContainsRune(host, ':') {
 				host = host + ":465" // Default to smtps port
+			} else {
+				serverName = host[:strings.IndexRune(host, ':')]
 			}
-			conn, err = smtp.DialTLS(host, &tls.Config{})
+			conn, err = smtp.DialTLS(host, &tls.Config{
+				ServerName: serverName,
+			})
 			if err != nil {
 				return 0, err
 			}