all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* smtpmail-smtp-server function?
@ 2009-03-18 18:46 Sean O'Rourke
  2009-03-20 19:32 ` Ted Zlatanov
  0 siblings, 1 reply; 3+ messages in thread
From: Sean O'Rourke @ 2009-03-18 18:46 UTC (permalink / raw)
  To: emacs-devel

My home and work networks have different SMTP servers
(irritatingly not named "smtp"), so frequently I have to manually
change smtpmail-smtp-server.  Does anyone else think it would be
useful to allow smtpmail-smtp-server to be a function returning
the SMTP server name?

Sean




^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: smtpmail-smtp-server function?
  2009-03-18 18:46 smtpmail-smtp-server function? Sean O'Rourke
@ 2009-03-20 19:32 ` Ted Zlatanov
  2009-04-02  4:41   ` Sean O'Rourke
  0 siblings, 1 reply; 3+ messages in thread
From: Ted Zlatanov @ 2009-03-20 19:32 UTC (permalink / raw)
  To: emacs-devel

On Wed, 18 Mar 2009 11:46:54 -0700 "Sean O'Rourke" <seano@cs.ucsd.edu> wrote: 

SO> My home and work networks have different SMTP servers
SO> (irritatingly not named "smtp"), so frequently I have to manually
SO> change smtpmail-smtp-server.  Does anyone else think it would be
SO> useful to allow smtpmail-smtp-server to be a function returning
SO> the SMTP server name?

Yes.  I do it differently inside Gnus, but it would be a nice
general-purpose improvement.

Ted





^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: smtpmail-smtp-server function?
  2009-03-20 19:32 ` Ted Zlatanov
@ 2009-04-02  4:41   ` Sean O'Rourke
  0 siblings, 0 replies; 3+ messages in thread
From: Sean O'Rourke @ 2009-04-02  4:41 UTC (permalink / raw)
  To: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 805 bytes --]

Ted Zlatanov <tzz@lifelogs.com> writes:

> On Wed, 18 Mar 2009 11:46:54 -0700 "Sean O'Rourke" <seano@cs.ucsd.edu> 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.

/s

2009-04-02  Sean O'Rourke  <seano@cs.ucla.edu>

	* 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.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: smtp.diff --]
[-- Type: text/x-patch, Size: 2248 bytes --]

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 smtpmail-smtp-server))))
+	      (tracer (concat "trace.*smtp.*" (regexp-quote (smtpmail-get-smtp-server)))))
 	  (mapcar
 	   '(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:

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2009-04-02  4:41 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-03-18 18:46 smtpmail-smtp-server function? Sean O'Rourke
2009-03-20 19:32 ` Ted Zlatanov
2009-04-02  4:41   ` Sean O'Rourke

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.