all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Ryan Tate via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
To: 38066@debbugs.gnu.org
Subject: bug#38066: 26.1; X-Message-SMTP-Method header does not affect smtpmail-stream-type
Date: Mon, 04 Nov 2019 23:45:52 -0500	[thread overview]
Message-ID: <87ftj3j5hb.fsf@disp2634> (raw)

The internal emacs mail header X-Message-SMTP-Method is described in
section 3.3 of the manual as a way to get "some messages to go via one
mail server, and other messages to go through another." Both examples
given show that this header can be used to communicate a method, server
name, and port.
https://www.gnu.org/software/emacs/manual/html_node/message/Mail-Variables.html

However, emacs, in particular gnus/message.el when sending through
smtpmail.el, fails to adjust the variable smtpmail-smtp-stream type to
match the port. So, for example, if a user selects port 465, the
connection will fail as this is the port for SMTP connections with
TLS.

Port 587 will happen to work as this is the port for SMTP with STARTTLS,
and STARTTLS upgrades can happen in a plain stream type (the smtpmail
default). But emacs will not (and does not provide an option to) force
STARTTLS when port 587 is specified as would occur if 'ssl were supplied
as the value for smtpmail-stream-type. This provides an avenue under
which encryption may be silently dropped. 

There is no warning in the manual that port 465 will not function as
expected using the X-Message-SMTP-Method header.

There is also no mechanism through which a stream may be user specified
via the X-Message-SMTP-Method header.

I believe the ideal solution here is for emacs to either auto-associate
ports with their usual stream types (465->'ssl, 587->'starttls, 25->nil)
or provide a mechanism for stream type to be specified in the header as
the fifth value (after method, machine, port, alt username). Or
auto-associate by default and provide a config variable through which to
override stream type by machine and port.

Personally I am working around this with the following hook. (Due to
changes to emacs in subsequent versions, it needs to work with both
strings and numbers as the port):

(defun set-smtpmail-stream-type-from-port ()
  (when (or (equal smtpmail-smtp-service "465")
	    (equal smtpmail-smtp-service 465))
    (setq smtpmail-stream-type 'ssl))
  (when (or (equal smtpmail-smtp-service "587")
	    (equal smtpmail-smtp-service 587))
    (setq smtpmail-stream-type 'starttls))
  (when (or (equal smtpmail-smtp-service "25")
	    (equal smtpmail-smtp-service 25))
    (setq smtpmail-stream-type nil))
  )

(add-hook 'message-send-mail-hook #'set-smtpmail-stream-type-from-port)



In GNU Emacs 26.1 (build 2, x86_64-pc-linux-gnu, GTK+ Version 3.24.4)
 of 2019-02-03, modified by Debian built on zam904
Windowing system distributor 'The X.Org Foundation', version 11.0.12004000
System Description:	Debian GNU/Linux 10 (buster)

Recent messages:
Loading /etc/emacs/site-start.d/50autoconf.el (source)...done
Loading /etc/emacs/site-start.d/50dictionaries-common.el (source)...
Loading debian-ispell...
Loading /var/cache/dictionaries-common/emacsen-ispell-default.el (source)...done
Loading debian-ispell...done
Loading /var/cache/dictionaries-common/emacsen-ispell-dicts.el (source)...done
Loading /etc/emacs/site-start.d/50dictionaries-common.el (source)...done
For information about GNU Emacs and the GNU system, type C-h C-a.
Mark set [4 times]
Auto-saving...done

Configured using:
 'configure --build x86_64-linux-gnu --prefix=/usr
 --sharedstatedir=/var/lib --libexecdir=/usr/lib
 --localstatedir=/var/lib --infodir=/usr/share/info
 --mandir=/usr/share/man --enable-libsystemd --with-pop=yes
 --enable-locallisppath=/etc/emacs:/usr/local/share/emacs/26.1/site-lisp:/usr/local/share/emacs/site-lisp:/usr/share/emacs/26.1/site-lisp:/usr/share/emacs/site-lisp
 --with-sound=alsa --without-gconf --with-mailutils --build
 x86_64-linux-gnu --prefix=/usr --sharedstatedir=/var/lib
 --libexecdir=/usr/lib --localstatedir=/var/lib
 --infodir=/usr/share/info --mandir=/usr/share/man --enable-libsystemd
 --with-pop=yes
 --enable-locallisppath=/etc/emacs:/usr/local/share/emacs/26.1/site-lisp:/usr/local/share/emacs/site-lisp:/usr/share/emacs/26.1/site-lisp:/usr/share/emacs/site-lisp
 --with-sound=alsa --without-gconf --with-mailutils --with-x=yes
 --with-x-toolkit=gtk3 --with-toolkit-scroll-bars 'CFLAGS=-g -O2
 -fdebug-prefix-map=/build/emacs-26.1+1=. -fstack-protector-strong
 -Wformat -Werror=format-security -Wall' 'CPPFLAGS=-Wdate-time
 -D_FORTIFY_SOURCE=2' LDFLAGS=-Wl,-z,relro'

Configured features:
XPM JPEG TIFF GIF PNG RSVG IMAGEMAGICK SOUND GPM DBUS GSETTINGS NOTIFY
ACL LIBSELINUX GNUTLS LIBXML2 FREETYPE M17N_FLT LIBOTF XFT ZLIB
TOOLKIT_SCROLL_BARS GTK3 X11 THREADS LIBSYSTEMD LCMS2

Important settings:
  value of $LANG: en_US.UTF-8
  locale-coding-system: utf-8-unix

Major mode: Message[Notmuch]

Minor modes in effect:
  diff-auto-refine-mode: t
  mml-mode: t
  tooltip-mode: t
  global-eldoc-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  tool-bar-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  line-number-mode: t
  auto-fill-function: message-do-auto-fill
  transient-mark-mode: t
  abbrev-mode: t

Load-path shadows:
/usr/share/emacs/site-lisp/elpa/notmuch-0.28.4/notmuch-show hides /usr/share/emacs/site-lisp/elpa-src/notmuch-0.28.4/notmuch-show
/usr/share/emacs/site-lisp/elpa/notmuch-0.28.4/notmuch-jump hides /usr/share/emacs/site-lisp/elpa-src/notmuch-0.28.4/notmuch-jump
/usr/share/emacs/site-lisp/elpa/notmuch-0.28.4/notmuch-crypto hides /usr/share/emacs/site-lisp/elpa-src/notmuch-0.28.4/notmuch-crypto
/usr/share/emacs/site-lisp/elpa/notmuch-0.28.4/coolj hides /usr/share/emacs/site-lisp/elpa-src/notmuch-0.28.4/coolj
/usr/share/emacs/site-lisp/elpa/notmuch-0.28.4/notmuch-draft hides /usr/share/emacs/site-lisp/elpa-src/notmuch-0.28.4/notmuch-draft
/usr/share/emacs/site-lisp/elpa/notmuch-0.28.4/notmuch-compat hides /usr/share/emacs/site-lisp/elpa-src/notmuch-0.28.4/notmuch-compat
/usr/share/emacs/site-lisp/elpa/notmuch-0.28.4/notmuch-autoloads hides /usr/share/emacs/site-lisp/elpa-src/notmuch-0.28.4/notmuch-autoloads
/usr/share/emacs/site-lisp/elpa/notmuch-0.28.4/notmuch-company hides /usr/share/emacs/site-lisp/elpa-src/notmuch-0.28.4/notmuch-company
/usr/share/emacs/site-lisp/elpa/notmuch-0.28.4/notmuch-query hides /usr/share/emacs/site-lisp/elpa-src/notmuch-0.28.4/notmuch-query
/usr/share/emacs/site-lisp/elpa/notmuch-0.28.4/notmuch-hello hides /usr/share/emacs/site-lisp/elpa-src/notmuch-0.28.4/notmuch-hello
/usr/share/emacs/site-lisp/elpa/notmuch-0.28.4/notmuch-message hides /usr/share/emacs/site-lisp/elpa-src/notmuch-0.28.4/notmuch-message
/usr/share/emacs/site-lisp/elpa/notmuch-0.28.4/make-deps hides /usr/share/emacs/site-lisp/elpa-src/notmuch-0.28.4/make-deps
/usr/share/emacs/site-lisp/elpa/notmuch-0.28.4/notmuch-address hides /usr/share/emacs/site-lisp/elpa-src/notmuch-0.28.4/notmuch-address
/usr/share/emacs/site-lisp/elpa/notmuch-0.28.4/notmuch-parser hides /usr/share/emacs/site-lisp/elpa-src/notmuch-0.28.4/notmuch-parser
/usr/share/emacs/site-lisp/elpa/notmuch-0.28.4/notmuch-print hides /usr/share/emacs/site-lisp/elpa-src/notmuch-0.28.4/notmuch-print
/usr/share/emacs/site-lisp/elpa/notmuch-0.28.4/notmuch-tag hides /usr/share/emacs/site-lisp/elpa-src/notmuch-0.28.4/notmuch-tag
/usr/share/emacs/site-lisp/elpa/notmuch-0.28.4/notmuch-lib hides /usr/share/emacs/site-lisp/elpa-src/notmuch-0.28.4/notmuch-lib
/usr/share/emacs/site-lisp/elpa/notmuch-0.28.4/notmuch hides /usr/share/emacs/site-lisp/elpa-src/notmuch-0.28.4/notmuch
/usr/share/emacs/site-lisp/elpa/notmuch-0.28.4/notmuch-wash hides /usr/share/emacs/site-lisp/elpa-src/notmuch-0.28.4/notmuch-wash
/usr/share/emacs/site-lisp/elpa/notmuch-0.28.4/notmuch-maildir-fcc hides /usr/share/emacs/site-lisp/elpa-src/notmuch-0.28.4/notmuch-maildir-fcc
/usr/share/emacs/site-lisp/elpa/notmuch-0.28.4/notmuch-pkg hides /usr/share/emacs/site-lisp/elpa-src/notmuch-0.28.4/notmuch-pkg
/usr/share/emacs/site-lisp/elpa/notmuch-0.28.4/notmuch-tree hides /usr/share/emacs/site-lisp/elpa-src/notmuch-0.28.4/notmuch-tree
/usr/share/emacs/site-lisp/elpa/notmuch-0.28.4/notmuch-version hides /usr/share/emacs/site-lisp/elpa-src/notmuch-0.28.4/notmuch-version
/usr/share/emacs/site-lisp/elpa/notmuch-0.28.4/notmuch-mua hides /usr/share/emacs/site-lisp/elpa-src/notmuch-0.28.4/notmuch-mua

Features:
(shadow emacsbug sendmail sort gnus-alias mail-extr notmuch hl-line
notmuch-message notmuch-hello wid-edit notmuch-tree notmuch-show
notmuch-print notmuch-crypto notmuch-mua notmuch-draft
notmuch-maildir-fcc notmuch-address notmuch-company notmuch-parser
notmuch-wash diff-mode easy-mmode coolj notmuch-query goto-addr
thingatpt icalendar diary-lib diary-loaddefs cal-menu calendar
cal-loaddefs notmuch-tag edmacro kmacro crm notmuch-lib advice
notmuch-version notmuch-compat cl message rmc puny dired dired-loaddefs
format-spec rfc822 mml mailabbrev gmm-utils mailheader mm-view mml-smime
mml-sec epa derived epg gnus-util rmail rmail-loaddefs mail-utils smime
dig mm-decode mm-bodies mm-encode mailcap mail-parse rfc2231 rfc2047
rfc2045 mm-util ietf-drums mail-prsvr elec-pair finder-inf info package
easymenu epg-config url-handlers url-parse auth-source cl-seq eieio
eieio-core cl-macs eieio-loaddefs password-cache url-vars seq byte-opt
gv bytecomp byte-compile cconv cl-loaddefs cl-lib time-date mule-util
tooltip eldoc electric uniquify ediff-hook vc-hooks lisp-float-type
mwheel term/x-win x-win term/common-win x-dnd tool-bar dnd fontset image
regexp-opt fringe tabulated-list replace newcomment text-mode elisp-mode
lisp-mode prog-mode register page menu-bar rfn-eshadow isearch timer
select scroll-bar mouse jit-lock font-lock syntax facemenu font-core
term/tty-colors frame cl-generic cham georgian utf-8-lang misc-lang
vietnamese tibetan thai tai-viet lao korean japanese eucjp-ms cp51932
hebrew greek romanian slovak czech european ethiopic indian cyrillic
chinese composite charscript charprop case-table epa-hook jka-cmpr-hook
help simple abbrev obarray minibuffer cl-preloaded nadvice loaddefs
button faces cus-face macroexp files text-properties overlay sha1 md5
base64 format env code-pages mule custom widget hashtable-print-readable
backquote dbusbind inotify lcms2 dynamic-setting system-font-setting
font-render-setting move-toolbar gtk x-toolkit x multi-tty
make-network-process emacs)

Memory information:
((conses 16 260049 19820)
 (symbols 48 29943 6)
 (miscs 40 184 580)
 (strings 32 83885 3752)
 (string-bytes 1 2093686)
 (vectors 16 25869)
 (vector-slots 8 656309 21192)
 (floats 8 58 202)
 (intervals 56 493 19)
 (buffers 992 14))





             reply	other threads:[~2019-11-05  4:45 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-05  4:45 Ryan Tate via Bug reports for GNU Emacs, the Swiss army knife of text editors [this message]
2019-11-05 10:18 ` bug#38066: 26.1; X-Message-SMTP-Method header does not affect smtpmail-stream-type Robert Pluim
     [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=87ftj3j5hb.fsf@disp2634 \
    --to=bug-gnu-emacs@gnu.org \
    --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.