[Top][All Lists]

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

Re: smtpmail-smtp-server function?

From: Sean O'Rourke
Subject: Re: smtpmail-smtp-server function?
Date: Wed, 01 Apr 2009 21:41:03 -0700
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (darwin)

Ted Zlatanov <address@hidden> writes:

> On Wed, 18 Mar 2009 11:46:54 -0700 "Sean O'Rourke" <address@hidden> wrote: 
> SO> Does anyone else think it would be useful to allow
> SO> smtpmail-smtp-server to be a function returning the SMTP
> SO> server name?
> Yes.  I do it differently inside Gnus,

Would you mind sharing how?  I don't doubt that Gnus has such a
knob, but I haven't found it.

> but it would be a nice general-purpose improvement.

Patch lightly-tested and attached.


2009-04-02  Sean O'Rourke  <address@hidden>

        * mail/smtpmail.el (smtpmail-default-smtp-server): Allow a
        function name value.
        (smtpmail-smtp-server): Same.
        (smtpmail-get-smtp-server): New function to handle it.
        (smtpmail-via-smtp): Use it.

        * mail/feedmail.el (feedmail-buffer-to-smtpmail): Use it.

diff --git a/lisp/mail/feedmail.el b/lisp/mail/feedmail.el
index d0cbbb6..14fba61 100644
--- a/lisp/mail/feedmail.el
+++ b/lisp/mail/feedmail.el
@@ -1349,7 +1349,7 @@ complicated cases."
        (insert "Look for details below or in the *Messages* buffer.\n\n")
        (let ((case-fold-search t)
              ;; don't be overconfident about the name of the trace buffer
-             (tracer (concat "trace.*smtp.*" (regexp-quote 
+             (tracer (concat "trace.*smtp.*" (regexp-quote 
           '(lambda (buffy)
              (if (string-match tracer (buffer-name buffy))
diff --git a/lisp/mail/smtpmail.el b/lisp/mail/smtpmail.el
index c849c7e..7829b0a 100644
--- a/lisp/mail/smtpmail.el
+++ b/lisp/mail/smtpmail.el
@@ -89,13 +89,17 @@
 (defcustom smtpmail-default-smtp-server nil
   "Specify default SMTP server.
 This only has effect if you specify it before loading the smtpmail library."
-  :type '(choice (const nil) string)
+  :type '(choice (const nil) symbol string)
   :group 'smtpmail)
 (defcustom smtpmail-smtp-server
   (or (getenv "SMTPSERVER") smtpmail-default-smtp-server)
-  "The name of the host running SMTP server."
-  :type '(choice (const nil) string)
+  "The name of the host running the SMTP server.
+If it is a string, `smtpmail-smtp-server' is the SMTP server's
+name.  If it is a symbol, it is a function that returns the
+server's name."
+  :type '(choice (const nil) symbol string)
   :group 'smtpmail)
 (defcustom smtpmail-smtp-service 25
@@ -634,10 +638,15 @@ The list is in preference order.")
       (when (null (smtpmail-cred-passwd cred))
        (password-cache-add prompt passwd)))))
+(defun smtpmail-get-smtp-server ()
+  (cond
+   ((stringp smtpmail-smtp-server) smtpmail-smtp-server)
+   ((fboundp smtpmail-smtp-server)(funcall smtpmail-smtp-server))
+   (t (error "`smtpmail-smtp-server' not defined"))))
 (defun smtpmail-via-smtp (recipient smtpmail-text-buffer)
   (let ((process nil)
-       (host (or smtpmail-smtp-server
-                 (error "`smtpmail-smtp-server' not defined")))
+       (host (smtpmail-get-smtp-server))
        (port smtpmail-smtp-service)
         ;; smtpmail-mail-address should be set to the appropriate
         ;; buffer-local value by the caller, but in case not:

reply via email to

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