emacs-devel
[Top][All Lists]
Advanced

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

Default of message-send-mail-function (was: error from new Gnus / sendma


From: Reiner Steib
Subject: Default of message-send-mail-function (was: error from new Gnus / sendmail)
Date: Tue, 30 Oct 2007 23:55:19 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.50 (gnu/linux)

On Mon, Oct 29 2007, Stefan Monnier wrote:
> I needed the following patch to get Emacs to use
> message-send-mail-with-sendmail like it used to.  Not sure if that's
> the right fix.

I'm also not sure about this.

> +(require 'sendmail)                     ;So as to define sendmail-program.
>  ;; Useful to set in site-init.el
>  (defcustom message-send-mail-function
>    (let ((program (if (boundp 'sendmail-program)

If we require sendmail, there's no point in testing (boundp
'sendmail-program).  Additionally, in
`message-send-mail-with-sendmail' there are more tests.

In March 2006 there was some discussion about this on ding/emacs-devel:
<http://thread.gmane.org/gmane.emacs.gnus.general/62284/focus=62290>.
Back then, I suggested:

--8<---------------cut here---------------start------------->8---
(defun message-send-mail-function ()
  "Return suitable value for the variable `message-send-mail-function'."
  (cond ((and sendmail-program
              (executable-find sendmail-program))
         'message-send-mail-with-sendmail)
        ((and (locate-library "smtpmail")
              (require 'smtpmail)
              smtpmail-default-smtp-server)
         'message-smtpmail-send-it)
        ((locate-library "mailclient")
         'message-send-mail-with-mailclient)
        (t
         (lambda ()
           (error "Don't know how to send mail.  Please customize 
`message-send-mail-function'.")))))
--8<---------------cut here---------------end--------------->8---

Below is a patch (with an earlier version of the function
`message-send-mail-function').  I will look at the old messages
tomorrow.  Unless there's a better suggestion, I'll install something
alone these lines.

On Tue, Oct 30 2007, Dan Nicolaescu wrote:
> Sending...
> Sending via mail...
> smtpmail-via-smtp: `smtpmail-smtp-server' not defined
>
> It worked fine before, mail was sent with the local sendmail, I don't
> have any special settings.  
>
> Shouldn't this continue to work by default?

Yes.  I wonder why nobody complained about this before.

Bye, Reiner.


--8<---------------cut here---------------start------------->8---
Index: message.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/gnus/message.el,v
retrieving revision 1.102
diff -u -r1.102 message.el
--- message.el  24 Feb 2006 05:02:12 -0000      1.102
+++ message.el  16 Mar 2006 21:09:33 -0000
@@ -48,6 +48,7 @@
 (require 'mml)
 (require 'rfc822)
 (eval-and-compile
+  (autoload 'mailclient-send-it "mailclient") ;; Emacs 22 or contrib/
   (autoload 'gnus-find-method-for-group "gnus")
   (autoload 'nnvirtual-find-group-art "nnvirtual")
   (autoload 'gnus-group-decoded-name "gnus-group"))
@@ -584,16 +585,37 @@
   :link '(custom-manual "(message)Canceling News")
   :type 'string)
 
+(defun message-send-mail-function ()
+  "Return suitable value for the variable `message-send-mail-function'."
+  (cond ((and sendmail-program
+             (executable-find program))
+        'message-send-mail-with-sendmail)
+       ((and (locate-library "mailclient")
+             window-system
+             (memq system-type '(darwin windows-nt)))
+        'message-send-mail-with-mailclient)
+       (t
+        'message-smtpmail-send-it)))
+
+;; Prevent problems with `window-system' not having the correct value
+;; when loaddefs.el is loaded. `custom-reevaluate-setting' needs the
+;; standard value.
+;;;###autoload
+(put 'message-send-mail-function 'standard-value
+     '((message-send-mail-function)))
+
 ;; Useful to set in site-init.el
 ;;;###autoload
-(defcustom message-send-mail-function 'message-send-mail-with-sendmail
+(defcustom message-send-mail-function (message-send-mail-function)
   "Function to call to send the current buffer as mail.
 The headers should be delimited by a line whose contents match the
 variable `mail-header-separator'.
 
-Valid values include `message-send-mail-with-sendmail' (the default),
+Valid values include `message-send-mail-with-sendmail',
 `message-send-mail-with-mh', `message-send-mail-with-qmail',
-`message-smtpmail-send-it', `smtpmail-send-it' and `feedmail-send-it'.
+`message-smtpmail-send-it', `smtpmail-send-it',
+`feedmail-send-it' and `message-send-mail-with-mailclient'.  The
+default is system dependent.
 
 See also `send-mail-function'."
   :type '(radio (function-item message-send-mail-with-sendmail)
@@ -602,8 +624,11 @@
                (function-item message-smtpmail-send-it)
                (function-item smtpmail-send-it)
                (function-item feedmail-send-it)
+               (function-item message-send-mail-with-mailclient
+                              :tag "Use Mailclient package")
                (function :tag "Other"))
   :group 'message-sending
+  :initialize 'custom-initialize-default
   :link '(custom-manual "(message)Mail Variables")
   :group 'message-mail)
 
@@ -3982,6 +4007,13 @@
   (run-hooks 'message-send-mail-hook)
   (smtpmail-send-it))
 
+(defun message-send-mail-with-mailclient ()
+  "Send the prepared message buffer with `mailclient-send-it'.
+This only differs from `smtpmail-send-it' that this command evaluates
+`message-send-mail-hook' just before sending a message."
+  (run-hooks 'message-send-mail-hook)
+  (mailclient-send-it))
+
 (defun message-canlock-generate ()
   "Return a string that is non-trivial to guess.
 Do not use this for anything important, it is cryptographically weak."
--8<---------------cut here---------------end--------------->8---

-- 
       ,,,
      (o o)
---ooO-(_)-Ooo---  |  PGP key available  |  http://rsteib.home.pages.de/




reply via email to

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