2011-06-21 Lars Magne Ingebrigtsen <larsi@gnus.org>
+ * mail/smtpmail.el (smtpmail-via-smtp): Set
+ :use-starttls-if-possible so that we always use STARTTLS if the
+ server supports it. SMTP servers that support STARTTLS commonly
+ require it.
+
+ * net/network-stream.el (network-stream-open-starttls): Support
+ upgrading to STARTTLS always, even if we don't have built-in support.
+ (open-network-stream): Add the :always-query-capabilies keyword.
+
* mail/smtpmail.el: Rewritten to do opportunistic STARTTLS
upgrades with `open-network-stream', and rely solely on
auth-source for all credentials. Big changes throughout the file,
(lambda (capabilities)
(and (string-match "-STARTTLS" capabilities)
"STARTTLS\r\n"))
- :client-certificate t))
+ :client-certificate t
+ :use-starttls-if-possible t))
;; If we couldn't access the server at all, we give up.
(unless (setq process (car result))
certificate. This parameter will only be used when doing TLS
or STARTTLS connections.
+If :use-starttls-if-possible is non-nil, do opportunistic
+STARTTLS upgrades even if Emacs doesn't have built-in TLS
+functionality.
+
:nowait is a boolean that says the connection should be made
asynchronously, if possible."
(unless (featurep 'make-network-process)
;; If we have built-in STARTTLS support, try to upgrade the
;; connection.
(when (and (or (fboundp 'open-gnutls-stream)
- (and require-tls
+ (and (or require-tls
+ (plist-get parameters :use-starttls-if-possible))
(executable-find "gnutls-cli")))
capabilities success-string starttls-function
(setq starttls-command
starttls-extra-arguments)))
(setq stream (starttls-open-stream name buffer host service)))
(network-stream-get-response stream start eoc))
+ ;; Requery capabilities for protocols that require it; i.e.,
+ ;; EHLO for SMTP.
+ (when (plist-get parameters :always-query-capabilities)
+ (network-stream-command stream capability-command eoc))
(when (string-match success-string
(network-stream-command stream starttls-command eoc))
;; The server said it was OK to begin STARTTLS negotiations.