From: Robert Pluim <rpluim@gmail.com>
To: Ryan Tate <ryantate@ryantate.com>
Cc: 38066@debbugs.gnu.org
Subject: bug#38066: 26.1; X-Message-SMTP-Method header does not affect smtpmail-stream-type
Date: Tue, 05 Nov 2019 11:18:21 +0100 [thread overview]
Message-ID: <m2lfsu4oeq.fsf@gmail.com> (raw)
In-Reply-To: <87ftj3j5hb.fsf@disp2634> (Ryan Tate via's message of "Mon, 04 Nov 2019 23:45:52 -0500")
>>>>> On Mon, 04 Nov 2019 23:45:52 -0500, Ryan Tate said:
Ryan> I believe the ideal solution here is for emacs to either auto-associate
Ryan> ports with their usual stream types (465->'ssl, 587->'starttls, 25->nil)
Ryan> or provide a mechanism for stream type to be specified in the header as
Ryan> the fifth value (after method, machine, port, alt username). Or
Ryan> auto-associate by default and provide a config variable through which to
Ryan> override stream type by machine and port.
Iʼm not so sure about the auto association. How about we allow people
to ask for auto-detection? Something like the following (and then we
can discuss whether to turn it on by default, and I can argue that
STARTTLS is evil and we should force everyone to use 465 :-) )
Alternatively we could put this kind of code in open-network-stream,
to allow other protocols to benefit from the same kind of detection.
diff --git a/lisp/mail/smtpmail.el b/lisp/mail/smtpmail.el
index 9cf28fbe8a..75b15a99aa 100644
--- a/lisp/mail/smtpmail.el
+++ b/lisp/mail/smtpmail.el
@@ -98,11 +98,13 @@ smtpmail-stream-type
"Type of SMTP connections to use.
This may be either nil (upgrade with STARTTLS if possible),
`starttls' (refuse to send if STARTTLS isn't available),
-`plain' (never use STARTTLS), or `ssl' (to use TLS/SSL)."
- :version "24.1"
+`plain' (never use STARTTLS), or `ssl' (to use TLS/SSL), or
+`auto' to derive the stream-type from the port number."
+ :version "27.1"
:type '(choice (const :tag "Possibly upgrade to STARTTLS" nil)
(const :tag "Always use STARTTLS" starttls)
(const :tag "Never use STARTTLS" plain)
+ (const :tag "Derive from port number" auto)
(const :tag "Use TLS/SSL" ssl)))
(defcustom smtpmail-sendto-domain nil
@@ -666,6 +668,16 @@ smtpmail-user-mail-address
(string-match "\\." (cadr parts))
user-mail-address))))
+(defun smtpmail-derive-stream-type (stream-type port)
+ (if (equal stream-type 'auto)
+ (cdr (assoc port '((465 . ssl)
+ ("465" . ssl)
+ (587 . starttls)
+ ("587" . starttls)
+ (25 . nil)
+ ("25" . nil))))
+ stream-type))
+
(defun smtpmail-via-smtp (recipient smtpmail-text-buffer
&optional ask-for-password
send-attempts)
@@ -712,7 +724,9 @@ smtpmail-via-smtp
;; FIXME: Should we use raw-text-dos coding system to handle the r\n
;; for us?
(let ((coding-system-for-read 'binary)
- (coding-system-for-write 'binary))
+ (coding-system-for-write 'binary)
+ (smtpmail-stream-type
+ (smtpmail-derive-stream-type smtpmail-stream-type port)))
(setq result
(open-network-stream
"smtpmail" process-buffer host port
next prev parent reply other threads:[~2019-11-05 10:18 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-11-05 4:45 bug#38066: 26.1; X-Message-SMTP-Method header does not affect smtpmail-stream-type Ryan Tate via Bug reports for GNU Emacs, the Swiss army knife of text editors
2019-11-05 10:18 ` Robert Pluim [this message]
[not found] ` <87o8xqcn8v.fsf@disp2634>
2019-11-05 17:24 ` Robert Pluim
2019-11-05 17:42 ` Lars Ingebrigtsen
2019-11-05 17:53 ` Robert Pluim
2019-11-05 18:23 ` Lars Ingebrigtsen
2019-11-05 20:09 ` Robert Pluim
2019-11-08 20:56 ` Lars Ingebrigtsen
2020-08-20 15:05 ` Lars Ingebrigtsen
2019-11-05 17:57 ` Andreas Schwab
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=m2lfsu4oeq.fsf@gmail.com \
--to=rpluim@gmail.com \
--cc=38066@debbugs.gnu.org \
--cc=ryantate@ryantate.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.