emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] Reviving qmail with X-Message-SMTP-Method in Gnus


From: Andrew Cohen
Subject: Re: [PATCH] Reviving qmail with X-Message-SMTP-Method in Gnus
Date: Thu, 04 May 2023 15:32:04 +0800
User-agent: Gnus/5.13 (Gnus v5.13)

>>>>> "EZ" == Eli Zaretskii <eliz@gnu.org> writes:

    >> >From 13e47efe3c15e7afe3f6db98681e31125d199f58 Mon Sep 17
    >> 00:00:00 2001 From: Mohsen Banan <form@mohsen.banan.1.byname.net>
    >> Date: Wed, 26 Apr 2023 18:35:13 -0700 Subject: [PATCH] Reviving
    >> qmail with X-Message-SMTP-Method in Gnus
    >> 
    >> --- lisp/gnus/message.el | 2 ++ 1 file changed, 2 insertions(+)
    >> 
    >> diff --git a/lisp/gnus/message.el b/lisp/gnus/message.el index
    >> 7a71ac9f58e..865e5c99000 100644 --- a/lisp/gnus/message.el +++
    >> b/lisp/gnus/message.el @@ -5017,6 +5017,8 @@
    >> message-multi-smtp-send-mail (cond ((equal (car method)
    >> "sendmail") (message-send-mail-with-sendmail)) + ((equal (car
    >> method) "qmail") + (message-send-mail-with-qmail)) ((equal (car
    >> method) "smtp") (require 'smtpmail) (let*
    >> ((smtpmail-store-queue-variables t) -- 2.30.2

    EZ> Andrew, Lars: any objections to adding this to message.el?

Err, yes I object (sort of)! message.el knows how to handle 4 MTAs:
sendmail, qmail, mh, and mailclient.  The header X-Message-SMTP-Method
can be used to override the default MTA but for some reason only allows
sendmail (or the use of smtp directly).  The suggested patch would also
allow qmail. But the better way to handle this is to allow any of the
MTAs to be used. I suggest the following patch instead which will do
this (and in the unlikely event that another MTA is added to message.el
it would not require any further modification to handle the new MTA). Unless
there is some objection I'll push this instead.

>From bc25ec11c0c56ccf0d57adec839e5c640f97b725 Mon Sep 17 00:00:00 2001
From: Andrew G Cohen <cohen@andy.bu.edu>
Date: Wed, 3 May 2023 11:37:45 +0800
Subject: [PATCH 2/2] Allow X-Message-SMTP-Method to include more MTAs

* lisp/gnus/message.el (message-multi-smtp-send-mail): Allow the
X-Message-SMTP-Method header to override the default mailer with not
only smtp and sendmail but other MTAs as well.
---
 lisp/gnus/message.el | 38 +++++++++++++++++++++-----------------
 1 file changed, 21 insertions(+), 17 deletions(-)

diff --git a/lisp/gnus/message.el b/lisp/gnus/message.el
index 8d3fe010af4..3f7ce06f365 100644
--- a/lisp/gnus/message.el
+++ b/lisp/gnus/message.el
@@ -5007,30 +5007,34 @@ message-multi-smtp-send-mail
   "Send the current buffer to `message-send-mail-function'.
 Or, if there's a header that specifies a different method, use
 that instead."
-  (let ((method (message-field-value "X-Message-SMTP-Method")))
+  (let ((method (message-field-value "X-Message-SMTP-Method"))
+        send-function)
     (if (not method)
-       (funcall message-send-mail-function)
+        (funcall message-send-mail-function)
       (message-remove-header "X-Message-SMTP-Method")
       (setq method (split-string method))
+      (setq send-function
+            (symbol-function
+             (intern-soft (format "message-send-mail-with-%s" (car method)))))
       (cond
-       ((equal (car method) "sendmail")
-       (message-send-mail-with-sendmail))
        ((equal (car method) "smtp")
-       (require 'smtpmail)
-       (let* ((smtpmail-store-queue-variables t)
+        (require 'smtpmail)
+        (let* ((smtpmail-store-queue-variables t)
                (smtpmail-smtp-server (nth 1 method))
-              (service (nth 2 method))
-              (port (string-to-number service))
-              ;; If we're talking to the TLS SMTP port, then force a
-              ;; TLS connection.
-              (smtpmail-stream-type (if (= port 465)
-                                        'tls
-                                      smtpmail-stream-type))
-              (smtpmail-smtp-service (if (> port 0) port service))
-              (smtpmail-smtp-user (or (nth 3 method) smtpmail-smtp-user)))
-         (message-smtpmail-send-it)))
+               (service (nth 2 method))
+               (port (string-to-number service))
+               ;; If we're talking to the TLS SMTP port, then force a
+               ;; TLS connection.
+               (smtpmail-stream-type (if (= port 465)
+                                         'tls
+                                       smtpmail-stream-type))
+               (smtpmail-smtp-service (if (> port 0) port service))
+               (smtpmail-smtp-user (or (nth 3 method) smtpmail-smtp-user)))
+          (message-smtpmail-send-it)))
+       (send-function
+        (funcall send-function))
        (t
-       (error "Unknown method %s" method))))))
+        (error "Unknown mail method %s" method))))))
 
 (defun message-send-mail-with-sendmail ()
   "Send off the prepared buffer with sendmail."
-- 
2.40.0




-- 
Andrew Cohen



reply via email to

[Prev in Thread] Current Thread [Next in Thread]