Announcements and discussions for Gnus, the GNU Emacs Usenet newsreader
 help / color / mirror / Atom feed
* fs-change-smtp and draft messages
@ 2007-08-14 11:19 Hadron
  2007-08-14 13:24 ` Tassilo Horn
       [not found] ` <mailman.4764.1187097864.32220.info-gnus-english@gnu.org>
  0 siblings, 2 replies; 10+ messages in thread
From: Hadron @ 2007-08-14 11:19 UTC (permalink / raw)
  To: info-gnus-english


I have a problem with draft messages that I hope someone can help me
with.

If I save a message to drafts and then edit it at a later date (press
"e" - calls function gnus-draft-edit-message) then the call to the hook
fs-change-smtp doesn't respect the existing "from" field in the draft.

,----
| (defun fs-change-smtp ()
|   "Change the SMTP server according to the current from line."
|   (setq smtpmail-starttls-credentials '(("smtp.gmail.com" 587 nil nil)))
|   (setq message-send-mail-function 'smtpmail-send-it)
|   (save-excursion
|     (let ((from
|            (save-restriction
|              (message-narrow-to-headers)
|              (message-fetch-field "from"))))
|       (message "%s" from)
|       (message "**** From is `%s', setting `smtpmail-smtp-server' to `%s'"
|                from
|                (cond
| 		((string-match ".*adron.*" from)
|  		 (setq smtpmail-auth-credentials '(("smtp.gmail.com" 587 "hadronquark" "*******"))))
|                 ((string-match ".*default.*" from)
| 		 (setq smtpmail-auth-credentials '(("smtp.gmail.com" 587 "otheremails" "********"))))
| 		(t
| 		 (setq smtpmail-auth-credentials '(("smtp.gmail.com" 587 "default" "********")))
|                )))))
| )
| 
| (add-hook 'message-setup-hook 'fs-change-smtp)
`----

Despite the draft containing a field

"From: Hadron <hadronquark@googlemail.com>"

the "from" returned by message-fetch-field is another email address from
my address book. It is not getting the "From" field from the draft - or
doesn't appear to be.

This results in the smtp-auth-credentials being set incorrectly.

Any hint/tips on how to correct this?

The strange thing is that the from line above is the one displayed in
the draft edit buffer. It's only when I actually send the message are the
are the wrong smtp credentials used.

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

* Re: fs-change-smtp and draft messages
  2007-08-14 11:19 fs-change-smtp and draft messages Hadron
@ 2007-08-14 13:24 ` Tassilo Horn
       [not found] ` <mailman.4764.1187097864.32220.info-gnus-english@gnu.org>
  1 sibling, 0 replies; 10+ messages in thread
From: Tassilo Horn @ 2007-08-14 13:24 UTC (permalink / raw)
  To: info-gnus-english

Hadron <hadronquark@googlemail.com> writes:

Hi Hadron,

> If I save a message to drafts and then edit it at a later date (press
> "e" - calls function gnus-draft-edit-message) then the call to the
> hook fs-change-smtp doesn't respect the existing "from" field in the
> draft.

Sure, because the message buffer doesn't neet to be setup then.  You
added `fs-change-smtp' to `message-setup-hook', whereas
`message-send-hook' would be much more appropriate.

> ,----
> | (defun fs-change-smtp ()
> |   "Change the SMTP server according to the current from line."
> |   (setq smtpmail-starttls-credentials '(("smtp.gmail.com" 587 nil nil)))
> |   (setq message-send-mail-function 'smtpmail-send-it)
> |   (save-excursion
> |     (let ((from
> |            (save-restriction
> |              (message-narrow-to-headers)
> |              (message-fetch-field "from"))))
> |       (message "%s" from)
> |       (message "**** From is `%s', setting `smtpmail-smtp-server' to `%s'"
> |                from
> |                (cond
> | 		((string-match ".*adron.*" from)
> |  		 (setq smtpmail-auth-credentials '(("smtp.gmail.com" 587 "hadronquark" "*******"))))
> |                 ((string-match ".*default.*" from)
> | 		 (setq smtpmail-auth-credentials '(("smtp.gmail.com" 587 "otheremails" "********"))))
> | 		(t
> | 		 (setq smtpmail-auth-credentials '(("smtp.gmail.com" 587 "default" "********")))
> |                )))))
> | )
> | 
> | (add-hook 'message-setup-hook 'fs-change-smtp)
> `----

Bye,
Tassilo
-- 
Chuck Norris once roundhouse-kicked a ten dollar bill into 200 nickels. 

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

* Re: fs-change-smtp and draft messages
       [not found] ` <mailman.4764.1187097864.32220.info-gnus-english@gnu.org>
@ 2007-08-14 13:54   ` Hadron
  2007-08-14 15:28     ` Slackrat
  2007-08-14 15:14   ` Hadron
  1 sibling, 1 reply; 10+ messages in thread
From: Hadron @ 2007-08-14 13:54 UTC (permalink / raw)
  To: info-gnus-english

Tassilo Horn <tassilo@member.fsf.org> writes:

> Hadron <hadronquark@googlemail.com> writes:
>
> Hi Hadron,
>
>> If I save a message to drafts and then edit it at a later date (press
>> "e" - calls function gnus-draft-edit-message) then the call to the
>> hook fs-change-smtp doesn't respect the existing "from" field in the
>> draft.
>
> Sure, because the message buffer doesn't neet to be setup then.  You
> added `fs-change-smtp' to `message-setup-hook', whereas
> `message-send-hook' would be much more appropriate.

Ye gods. That must have been some careless global changes I made.

The question remains though and possibly you could explain it to me (I
cant follow the lisp), why is message setup hook being called for
editing a draft, and even though it is (was) why is it not picking up
the existing "From" field that is there in the draft?

>
>> ,----
>> | (defun fs-change-smtp ()
>> |   "Change the SMTP server according to the current from line."
>> |   (setq smtpmail-starttls-credentials '(("smtp.gmail.com" 587 nil nil)))
>> |   (setq message-send-mail-function 'smtpmail-send-it)
>> |   (save-excursion
>> |     (let ((from
>> |            (save-restriction
>> |              (message-narrow-to-headers)
>> |              (message-fetch-field "from"))))
>> |       (message "%s" from)
>> |       (message "**** From is `%s', setting `smtpmail-smtp-server' to `%s'"
>> |                from
>> |                (cond
>> | 		((string-match ".*adron.*" from)
>> |  		 (setq smtpmail-auth-credentials '(("smtp.gmail.com" 587 "hadronquark" "*******"))))
>> |                 ((string-match ".*default.*" from)
>> | 		 (setq smtpmail-auth-credentials '(("smtp.gmail.com" 587 "otheremails" "********"))))
>> | 		(t
>> | 		 (setq smtpmail-auth-credentials '(("smtp.gmail.com" 587 "default" "********")))
>> |                )))))
>> | )
>> | 
>> | (add-hook 'message-setup-hook 'fs-change-smtp)
>> `----
>
> Bye,
> Tassilo

-- 

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

* Re: fs-change-smtp and draft messages
       [not found] ` <mailman.4764.1187097864.32220.info-gnus-english@gnu.org>
  2007-08-14 13:54   ` Hadron
@ 2007-08-14 15:14   ` Hadron
  2007-08-14 15:39     ` Slackrat
                       ` (2 more replies)
  1 sibling, 3 replies; 10+ messages in thread
From: Hadron @ 2007-08-14 15:14 UTC (permalink / raw)
  To: info-gnus-english

Tassilo Horn <tassilo@member.fsf.org> writes:

> Hadron <hadronquark@googlemail.com> writes:
>
> Hi Hadron,
>
>> If I save a message to drafts and then edit it at a later date (press
>> "e" - calls function gnus-draft-edit-message) then the call to the
>> hook fs-change-smtp doesn't respect the existing "from" field in the
>> draft.
>
> Sure, because the message buffer doesn't neet to be setup then.  You
> added `fs-change-smtp' to `message-setup-hook', whereas
> `message-send-hook' would be much more appropriate.

I found this thread too where you recommend `message-send-mail-hook'
instead. Which would you say is better?

http://tinyurl.com/2n7axc

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

* Re: fs-change-smtp and draft messages
  2007-08-14 13:54   ` Hadron
@ 2007-08-14 15:28     ` Slackrat
  0 siblings, 0 replies; 10+ messages in thread
From: Slackrat @ 2007-08-14 15:28 UTC (permalink / raw)
  To: info-gnus-english

Hadron <hadronquark@googlemail.com> writes:

> Tassilo Horn <tassilo@member.fsf.org> writes:
>
>> Hadron <hadronquark@googlemail.com> writes:
>>
>> Hi Hadron,
>>
>>> If I save a message to drafts and then edit it at a later date (press
>>> "e" - calls function gnus-draft-edit-message) then the call to the
>>> hook fs-change-smtp doesn't respect the existing "from" field in the
>>> draft.
>>
>> Sure, because the message buffer doesn't neet to be setup then.  You
>> added `fs-change-smtp' to `message-setup-hook', whereas
>> `message-send-hook' would be much more appropriate.
>
> Ye gods. That must have been some careless global changes I made.
>
> The question remains though and possibly you could explain it to me (I
> cant follow the lisp), why is message setup hook being called for
> editing a draft, and even though it is (was) why is it not picking up
> the existing "From" field that is there in the draft?
>
>>
>>> ,----
>>> | (defun fs-change-smtp ()
>>> |   "Change the SMTP server according to the current from line."
>>> |   (setq smtpmail-starttls-credentials '(("smtp.gmail.com" 587 nil nil)))
>>> |   (setq message-send-mail-function 'smtpmail-send-it)
>>> |   (save-excursion
>>> |     (let ((from
>>> |            (save-restriction
>>> |              (message-narrow-to-headers)
>>> |              (message-fetch-field "from"))))
>>> |       (message "%s" from)
>>> |       (message "**** From is `%s', setting `smtpmail-smtp-server' to `%s'"
>>> |                from
>>> |                (cond
>>> | 		((string-match ".*adron.*" from)
>>> |  		 (setq smtpmail-auth-credentials '(("smtp.gmail.com" 587 "hadronquark" "*******"))))
>>> |                 ((string-match ".*default.*" from)
>>> | 		 (setq smtpmail-auth-credentials '(("smtp.gmail.com" 587 "otheremails" "********"))))
>>> | 		(t
>>> | 		 (setq smtpmail-auth-credentials '(("smtp.gmail.com" 587 "default" "********")))
>>> |                )))))
>>> | )
>>> | 
>>> | (add-hook 'message-setup-hook 'fs-change-smtp)
>>> `----
>>
>> Bye,
>> Tassilo
>
> -- 
TEST IGNORE

-- 
SlackRat - No 4Q to Reply

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

* Re: fs-change-smtp and draft messages
  2007-08-14 15:14   ` Hadron
@ 2007-08-14 15:39     ` Slackrat
  2007-08-14 16:39     ` Tassilo Horn
       [not found]     ` <mailman.4771.1187109611.32220.info-gnus-english@gnu.org>
  2 siblings, 0 replies; 10+ messages in thread
From: Slackrat @ 2007-08-14 15:39 UTC (permalink / raw)
  To: info-gnus-english

Hadron <hadronquark@googlemail.com> writes:

> Tassilo Horn <tassilo@member.fsf.org> writes:
>
>> Hadron <hadronquark@googlemail.com> writes:
>>
>> Hi Hadron,
>>
>>> If I save a message to drafts and then edit it at a later date (press
>>> "e" - calls function gnus-draft-edit-message) then the call to the
>>> hook fs-change-smtp doesn't respect the existing "from" field in the
>>> draft.
>>
>> Sure, because the message buffer doesn't neet to be setup then.  You
>> added `fs-change-smtp' to `message-setup-hook', whereas
>> `message-send-hook' would be much more appropriate.
>
> I found this thread too where you recommend `message-send-mail-hook'
> instead. Which would you say is better?
>
> http://tinyurl.com/2n7axc
>
>
I just sent the other message here having saved it as a draft, closing
gnus and editing it upon reentry

The "From" field was perfect

However, the "To" field was missing although upon sending it, it found
its way to the correct group and also included the correct "face"
headers (I have two)

Interesting ;)

-- 
SlackRat - No 4Q to Reply
-
As long as there are slaughterhouses, there will be battlefields.
-Leo Tolstoy

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

* Re: fs-change-smtp and draft messages
  2007-08-14 15:14   ` Hadron
  2007-08-14 15:39     ` Slackrat
@ 2007-08-14 16:39     ` Tassilo Horn
  2007-08-14 17:22       ` Leo
       [not found]     ` <mailman.4771.1187109611.32220.info-gnus-english@gnu.org>
  2 siblings, 1 reply; 10+ messages in thread
From: Tassilo Horn @ 2007-08-14 16:39 UTC (permalink / raw)
  To: info-gnus-english

Hadron <hadronquark@googlemail.com> writes:

Hi Hadron,

>> Sure, because the message buffer doesn't neet to be setup then.  You
>> added `fs-change-smtp' to `message-setup-hook', whereas
>> `message-send-hook' would be much more appropriate.
>
> I found this thread too where you recommend `message-send-mail-hook'
> instead. Which would you say is better?

Ah, yes.  `message-send-mail-hook' is better because you don't have to
set any SMTP server when sending a news posting.

Bye,
Tassilo
-- 
The glass is neither half-full nor half-empty: it's twice as big as it
needs to be.

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

* Re: fs-change-smtp and draft messages
  2007-08-14 16:39     ` Tassilo Horn
@ 2007-08-14 17:22       ` Leo
  2007-08-14 18:39         ` Tassilo Horn
  0 siblings, 1 reply; 10+ messages in thread
From: Leo @ 2007-08-14 17:22 UTC (permalink / raw)
  To: info-gnus-english

On 2007-08-14 17:39 +0100, Tassilo Horn wrote:
>> I found this thread too where you recommend `message-send-mail-hook'
>> instead. Which would you say is better?
>
> Ah, yes.  `message-send-mail-hook' is better because you don't have to
> set any SMTP server when sending a news posting.

I am curious about how news posting work.

-- 
Leo <sdl.web AT gmail.com>                         (GPG Key: 9283AA3F)

         Gnus is one component of the Emacs operating system.

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

* Re: fs-change-smtp and draft messages
  2007-08-14 17:22       ` Leo
@ 2007-08-14 18:39         ` Tassilo Horn
  0 siblings, 0 replies; 10+ messages in thread
From: Tassilo Horn @ 2007-08-14 18:39 UTC (permalink / raw)
  To: info-gnus-english

Leo <sdl.web@gmail.com> writes:

Hi Leo,

> I am curious about how news posting work.

Via NNTP.

--8<---------------cut here---------------start------------->8---
RFC 977                                                    February 1986
Network News Transfer Protocol

3.10.  The POST command

3.10.1.  POST

   POST

   If posting is allowed, response code 340 is returned to indicate that
   the article to be posted should be sent. Response code 440 indicates
   that posting is prohibited for some installation-dependent reason.

   If posting is permitted, the article should be presented in the
   format specified by RFC850, and should include all required header
   lines. After the article's header and body have been completely sent
   by the client to the server, a further response code will be returned
   to indicate success or failure of the posting attempt.

   The text forming the header and body of the message to be posted
   should be sent by the client using the conventions for text received
   from the news server:  A single period (".") on a line indicates the
   end of the text, with lines starting with a period in the original
   text having that period doubled during transmission.

   No attempt shall be made by the server to filter characters, fold or
   limit lines, or otherwise process incoming text.  It is our intent
   that the server just pass the incoming message to be posted to the
   server installation's news posting software, which is separate from
   this specification.  See RFC850 for more details.

   Since most installations will want the client news program to allow
   the user to prepare his message using some sort of text editor, and
   transmit it to the server for posting only after it is composed, the
   client program should take note of the herald message that greeted it
   when the connection was first established. This message indicates
   whether postings from that client are permitted or not, and can be
   used to caution the user that his access is read-only if that is the
   case. This will prevent the user from wasting a good deal of time
   composing a message only to find posting of the message was denied.
   The method and determination of which clients and hosts may post is
   installation dependent and is not covered by this specification.
--8<---------------cut here---------------end--------------->8---

Bye,
Tassilo
-- 
People say that  if you play Microsoft CD's  backwards, you hear satanic
things,  but that's  nothing, because  if you  play them  forwards, they
install Windows.

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

* Re: fs-change-smtp and draft messages
       [not found]     ` <mailman.4771.1187109611.32220.info-gnus-english@gnu.org>
@ 2007-08-15  9:58       ` Hadron
  0 siblings, 0 replies; 10+ messages in thread
From: Hadron @ 2007-08-15  9:58 UTC (permalink / raw)
  To: info-gnus-english

Tassilo Horn <tassilo@member.fsf.org> writes:

> Hadron <hadronquark@googlemail.com> writes:
>
> Hi Hadron,
>
>>> Sure, because the message buffer doesn't neet to be setup then.  You
>>> added `fs-change-smtp' to `message-setup-hook', whereas
>>> `message-send-hook' would be much more appropriate.
>>
>> I found this thread too where you recommend `message-send-mail-hook'
>> instead. Which would you say is better?
>
> Ah, yes.  `message-send-mail-hook' is better because you don't have to
> set any SMTP server when sending a news posting.

I got smtp authorization errors when using message-send-mail-hook.

None for message-send-hook

No idea why.

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

end of thread, other threads:[~2007-08-15  9:58 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-08-14 11:19 fs-change-smtp and draft messages Hadron
2007-08-14 13:24 ` Tassilo Horn
     [not found] ` <mailman.4764.1187097864.32220.info-gnus-english@gnu.org>
2007-08-14 13:54   ` Hadron
2007-08-14 15:28     ` Slackrat
2007-08-14 15:14   ` Hadron
2007-08-14 15:39     ` Slackrat
2007-08-14 16:39     ` Tassilo Horn
2007-08-14 17:22       ` Leo
2007-08-14 18:39         ` Tassilo Horn
     [not found]     ` <mailman.4771.1187109611.32220.info-gnus-english@gnu.org>
2007-08-15  9:58       ` Hadron

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