From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Robert Pluim Newsgroups: gmane.emacs.bugs 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 Message-ID: References: <87ftj3j5hb.fsf@disp2634> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="248193"; mail-complaints-to="usenet@blaine.gmane.org" Cc: 38066@debbugs.gnu.org To: Ryan Tate Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue Nov 05 11:19:16 2019 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1iRvvc-0012LN-BF for geb-bug-gnu-emacs@m.gmane.org; Tue, 05 Nov 2019 11:19:12 +0100 Original-Received: from localhost ([::1]:42734 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iRvva-0003DU-Fm for geb-bug-gnu-emacs@m.gmane.org; Tue, 05 Nov 2019 05:19:10 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:56931) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iRvvT-0003BA-Fg for bug-gnu-emacs@gnu.org; Tue, 05 Nov 2019 05:19:04 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iRvvS-0004u1-Ao for bug-gnu-emacs@gnu.org; Tue, 05 Nov 2019 05:19:03 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:57323) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iRvvS-0004tt-7R for bug-gnu-emacs@gnu.org; Tue, 05 Nov 2019 05:19:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1iRvvR-00074h-Uc for bug-gnu-emacs@gnu.org; Tue, 05 Nov 2019 05:19:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Robert Pluim Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 05 Nov 2019 10:19:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 38066 X-GNU-PR-Package: emacs Original-Received: via spool by 38066-submit@debbugs.gnu.org id=B38066.157294911227146 (code B ref 38066); Tue, 05 Nov 2019 10:19:01 +0000 Original-Received: (at 38066) by debbugs.gnu.org; 5 Nov 2019 10:18:32 +0000 Original-Received: from localhost ([127.0.0.1]:37911 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1iRvuy-00073m-0B for submit@debbugs.gnu.org; Tue, 05 Nov 2019 05:18:32 -0500 Original-Received: from mail-wm1-f42.google.com ([209.85.128.42]:33812) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1iRvuv-00073V-Km for 38066@debbugs.gnu.org; Tue, 05 Nov 2019 05:18:30 -0500 Original-Received: by mail-wm1-f42.google.com with SMTP id v3so16126454wmh.1 for <38066@debbugs.gnu.org>; Tue, 05 Nov 2019 02:18:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:references:mail-copies-to:gmane-reply-to-list :date:in-reply-to:message-id:mime-version:content-transfer-encoding; bh=sLwd5Dko4BfB9k8GWsdcf8MEYF6avi8JHHtmz75QaVY=; b=PsD4k3nDhEQrzyPcL6a6hgZD0MTop7PpCW9E4CEeuKBepL+beff+5KfDteQpFhbSGO YR36+hfHEc/sy/c7sUA+wcrchGHQznMPpxnAq+55jbSnfa1rgAQoFuBq/mePXqrJLG/E pulkjxtRuVa7QFDHZPP3JDRJfZiKt0X6GGkIbJoPbZ0iD2KR3OrBWrh7OarVcY4rUion F//cVvb0PcIXQaWfWLY48f3tLlApzjqz+S4cgkgUIR3ktVtQ/LLOusN0DCJ3nJCEdFX0 /Ujuz8XiKpTS5xseY6WIwFlnlMBE0JgY5XYA3OE/2b38h9VtNr5q11wB2YP6JKbtldnm wTqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:mail-copies-to :gmane-reply-to-list:date:in-reply-to:message-id:mime-version :content-transfer-encoding; bh=sLwd5Dko4BfB9k8GWsdcf8MEYF6avi8JHHtmz75QaVY=; b=AZ3doQdAREKxeyEC1tuPg2hKoqbK3d6DQuHl5Rg9K9HXHDjS4lsKX/P0WoVftqjB8H clPWvnejtySbvlAYS3PxO20PsTksPnmAL5RGK2SxPTsTGPLF48YqbubFE6skJ9/FlUoO 1NZVRKKek6ogkIVumHB1uDTd3oWSmAbhUM26k4KJ3NyAHAiRR8ZL2Hnkc4DA+c7Bdd3j S8T1NoXI4DQ7mApEdG+NOfxh6Y06A/F9kp2ruywf5YRg8gEnm+MK7JxajoeCu9r2GBVB RrAZOtDKosPdsW2uSab+VvvVXBPHVyTYSv5tOZXltINrtPcmZ2Kl4dOr2Ylr57yT+XoO 31IA== X-Gm-Message-State: APjAAAXfGYQNjipZ2RdFg5+2iedoiv5x2hJUQPEr+InOQV0TbgrvNy2O Ou7oi0zc3pGFo3KrsdAqsNvNkbhh X-Google-Smtp-Source: APXvYqx9vTiD35OfHS4jvU3EnNf2mDVY1pZC7F6ciM7uvPRsNUS8FpcUjgRsbxwNqJ+FuSsRysvqVA== X-Received: by 2002:a1c:1d10:: with SMTP id d16mr3679684wmd.14.1572949103187; Tue, 05 Nov 2019 02:18:23 -0800 (PST) Original-Received: from rpluim-mac ([149.5.228.1]) by smtp.gmail.com with ESMTPSA id s21sm1089246wmh.28.2019.11.05.02.18.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Nov 2019 02:18:22 -0800 (PST) Mail-Copies-To: never Gmane-Reply-To-List: yes In-Reply-To: <87ftj3j5hb.fsf@disp2634> (Ryan Tate via's message of "Mon, 04 Nov 2019 23:45:52 -0500") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:170974 Archived-At: >>>>> 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-ass= ociate Ryan> ports with their usual stream types (465->'ssl, 587->'starttls, 2= 5->nil) Ryan> or provide a mechanism for stream type to be specified in the hea= der as Ryan> the fifth value (after method, machine, port, alt username). Or Ryan> auto-associate by default and provide a config variable through w= hich to Ryan> override stream type by machine and port. I=CA=BCm 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))) =20 (defcustom smtpmail-sendto-domain nil @@ -666,6 +668,16 @@ smtpmail-user-mail-address (string-match "\\." (cadr parts)) user-mail-address)))) =20 +(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