Gnus development mailing list
 help / color / mirror / Atom feed
From: Kevin Greiner <kgreiner@xpediantsolutions.com>
Subject: Re: message-send-mail-function, agent, and a day of work
Date: Thu, 15 Apr 2004 12:20:31 -0500	[thread overview]
Message-ID: <u8ygxma3k.fsf@xpediantsolutions.com> (raw)
In-Reply-To: <sd4qrl5ire.fsf@wes.hardakers.net>

Wes Hardaker <wes@hardakers.net> writes:

> I spent way too much time the other day figuring out why my simple
> code to switch smtp servers was not working and all.  I was properly
> setting every variable I could find documented, but the effect seemed
> to be nothing.  The end result was because I was running with the
> agent turned on, I was missing a variable that is not documented with
> the rest of them (which makes some sense, as all the agents stuff is
> in one place).
>
> The problem is essentially this:
>
> 1) when you read about sending mail, the documentation says that the
>    variable 'message-send-mail-function is consulted to figure out how
>    to send mail.  This is what I was trying to modify.
>
> 2) However, the agent has his own variable for what to do when sending
>    anything:  gnus-agent-send-mail-function.
>
> The problem is twofold: first, there is no reference to the second
> variable in least a warning in the documentation related to sending
> mail.  Since the agent is turned on by default now, this will likely
> confuse a lot of people.  Second, the second variable is independent
> of the first.  This is part of the confusion.  I think the most simple
> solution would be to make the second variable point to a different
> function which checks the value of the first variable and uses that
> at runtime.  By default they both point at the same value, however, if
> the first one changes the second one never picks up that change in
> value.
>
> The gnus-agent-send-mail-function variable is set in gnus-agentize as
> follows:
>
>   (unless gnus-agent-send-mail-function
>     (setq gnus-agent-send-mail-function
> 	  (or message-send-mail-real-function
> 	      message-send-mail-function)
> 	  message-send-mail-real-function 'gnus-agent-send-mail))
>
> I'm suggesting this would be better:
>
>   (defun gnus-agent-use-current-send-mail-function ()
>          (funcall (or message-send-mail-real-function
>                       message-send-mail-function)))
>
>   (unless gnus-agent-send-mail-function
>     (setq gnus-agent-send-mail-function
>           'gnus-agent-use-current-send-mail-function))
>
> This way dynamic changes to the message-send-mail-function are picked
> up, but it still allows for customization of the agent specifically if
> desired.
>
> Thoughts?

The setq that assigns gnus-agent-send-mail-function must also assign
message-send-mail-real-function so that the mail functions will be
redirected to gnus-agent-send-mail.  Since you left that out, the
agent's ability to queue mail for later transmission is lost.  If we
simply restore the missing assignment, we get an infinite loop as
gnus-agent-send-function calls
gnus-agent-use-current-send-mail-function which funcalls
message-send-mail-real-function (i.e. gnus-agent-send-mail).

Your configuration shouldn't be changing
message-send-mail-real-function so
gnus-agent-use-current-send-mail-function could be re-written to just
funcall message-send-mail-function.

Hmmm.... This should work but it means that the agent will ignore the
initial value of message-send-mail-real-function.  Not at all sure if
that is the right thing to do.

(defun gnus-agent-use-current-send-mail-function ()
       (funcall message-send-mail-function))

(unless gnus-agent-send-mail-function
  (setq gnus-agent-send-mail-function   'gnus-agent-use-current-send-mail-function
        message-send-mail-real-function 'gnus-agent-send-mail))


Now, one question, are you writing your smtp switch logic into the
function called by message-send-mail-function?  I believe that you
must, if you want offline mail to also be send via multiple smtp
servers.

Kevin



  reply	other threads:[~2004-04-15 17:20 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-04-15 16:05 Wes Hardaker
2004-04-15 17:20 ` Kevin Greiner [this message]
2004-04-15 18:26   ` Wes Hardaker
2004-04-15 20:28     ` Kevin Greiner
2004-04-15 20:35       ` Wes Hardaker
2004-04-15 23:50         ` Kevin Greiner
2004-04-16  4:09           ` Wes Hardaker

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=u8ygxma3k.fsf@xpediantsolutions.com \
    --to=kgreiner@xpediantsolutions.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).