info-gnus-english
[Top][All Lists]
Advanced

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

Re: fs-change-smtp and draft messages


From: Tassilo Horn
Subject: Re: fs-change-smtp and draft messages
Date: Tue, 14 Aug 2007 15:24:00 +0200
User-agent: Gnus/5.110007 (No Gnus v0.7) Emacs/22.1.50 (gnu/linux)

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. 





reply via email to

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