Implement the X-Message-SMTP-Method Message header
authorLars Ingebrigtsen <larsi@gnus.org>
Thu, 2 Feb 2012 13:24:08 +0000 (14:24 +0100)
committerLars Ingebrigtsen <larsi@gnus.org>
Thu, 2 Feb 2012 13:24:08 +0000 (14:24 +0100)
* lisp/message.el (message-multi-smtp-send-mail): New function.
(message-multi-smtp-send-mail): Respect the X-Message-SMTP-Method
header to implement multi-SMTP functionality.

* texi/message.texi (Mail Variables): Document X-Message-SMTP-Method.

GNUS-NEWS
lisp/ChangeLog
lisp/message.el
texi/ChangeLog
texi/message.texi

index f7bcd56..a580890 100644 (file)
--- a/GNUS-NEWS
+++ b/GNUS-NEWS
@@ -20,6 +20,11 @@ For older news, see Gnus info node "New Features".
 ** `backtab' in the summary buffer now selects the previous link in
    the article buffer.
 
+** Using the "X-Message-SMTP-Method" header in Message buffers now
+   allows specifying how messages are to be sent.  For example:
+
+   X-Message-SMTP-Method: smtp smtp.fsf.org 587
+   
 * For older news, see Gnus info node "New Features".
 
 ----------------------------------------------------------------------
index 3ccc906..6552159 100644 (file)
@@ -1,6 +1,8 @@
 2012-02-02  Lars Ingebrigtsen  <larsi@gnus.org>
 
        * message.el (message-multi-smtp-send-mail): New function.
+       (message-multi-smtp-send-mail): Respect the X-Message-SMTP-Method
+       header to implement multi-SMTP functionality.
 
        * gnus-agent.el (gnus-agent-send-mail-function): Removed.
        (gnus-agentize): Don't set it.
index e7bbff6..e925e8c 100644 (file)
@@ -4707,7 +4707,20 @@ If you always want Gnus to send messages in one piece, set
   "Send the current buffer to `message-send-mail-function'.
 Or, if there's a header that specifies a different method, use
 that instead."
-  (funcall message-send-mail-function))
+  (let ((method (message-field-value "X-Message-SMTP-Method")))
+    (if (not method)
+       (funcall message-send-mail-function)
+      (message-remove-header "X-Message-SMTP-Method")
+      (setq method (split-string method))
+      (cond
+       ((equal (car method) "sendmail")
+       (message-send-mail-with-sendmail))
+       ((equal (car method) "smtp")
+       (let ((smtpmail-smtp-server (nth 1 method))
+             (smtpmail-smtp-service (nth 2 method)))
+         (message-smtpmail-send-it)))
+       (t
+       (error "Unknown method %s" method))))))
 
 (defun message-send-mail-with-sendmail ()
   "Send off the prepared buffer with sendmail."
index 1884376..c573ee7 100644 (file)
@@ -1,3 +1,7 @@
+2012-02-02  Lars Ingebrigtsen  <larsi@gnus.org>
+
+       * message.texi (Mail Variables): Document X-Message-SMTP-Method.
+
 2012-01-31  Lars Ingebrigtsen  <larsi@gnus.org>
 
        * gnus.texi (Key Index): Change encoding to utf-8.
index f3ec8f8..cc3cadf 100644 (file)
@@ -1641,6 +1641,32 @@ To the thing similar to this, there is
 requires the @acronym{POP}-before-@acronym{SMTP} authentication.
 @xref{POP before SMTP, , POP before SMTP, gnus, The Gnus Manual}.
 
+@cindex X-Message-SMTP-Method
+If you have a complex @acronym{SMTP} setup, and want some messages to
+go via one mail server, and other messages to go through another, you
+can use the @samp{X-Message-SMTP-Method} header.  These are the
+supported values:
+
+@table @samp
+@item smtpmail
+
+@example
+X-Message-SMTP-Method: smtp smtp.fsf.org 587
+@end example
+
+This will send the message via @samp{smtp.fsf.org}, using port 587.
+
+@item sendmail
+
+@example
+X-Message-SMTP-Method: sendmail
+@end example
+
+This will send the message via the locally installed sendmail/exim/etc
+installation.
+
+@end table
+
 @item message-mh-deletable-headers
 @vindex message-mh-deletable-headers
 Most versions of MH doesn't like being fed messages that contain the