Pass ServerName to tls.Config for SMTP
This commit is contained in:
parent
33f2d4f9ee
commit
cc90cd2161
1 changed files with 12 additions and 2 deletions
|
@ -93,8 +93,11 @@ func SendMessage(aerc *widgets.Aerc, args []string) error {
|
||||||
switch scheme {
|
switch scheme {
|
||||||
case "smtp":
|
case "smtp":
|
||||||
host := uri.Host
|
host := uri.Host
|
||||||
|
serverName := uri.Host
|
||||||
if !strings.ContainsRune(host, ':') {
|
if !strings.ContainsRune(host, ':') {
|
||||||
host = host + ":587" // Default to submission port
|
host = host + ":587" // Default to submission port
|
||||||
|
} else {
|
||||||
|
serverName = host[:strings.IndexRune(host, ':')]
|
||||||
}
|
}
|
||||||
conn, err = smtp.Dial(host)
|
conn, err = smtp.Dial(host)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -108,7 +111,9 @@ func SendMessage(aerc *widgets.Aerc, args []string) error {
|
||||||
"Add smtp-starttls=yes")
|
"Add smtp-starttls=yes")
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
if err = conn.StartTLS(&tls.Config{}); err != nil {
|
if err = conn.StartTLS(&tls.Config{
|
||||||
|
ServerName: serverName,
|
||||||
|
}); err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -121,10 +126,15 @@ func SendMessage(aerc *widgets.Aerc, args []string) error {
|
||||||
}
|
}
|
||||||
case "smtps":
|
case "smtps":
|
||||||
host := uri.Host
|
host := uri.Host
|
||||||
|
serverName := uri.Host
|
||||||
if !strings.ContainsRune(host, ':') {
|
if !strings.ContainsRune(host, ':') {
|
||||||
host = host + ":465" // Default to smtps port
|
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 {
|
if err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue