[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
fs-change-smtp and draft messages
From: |
Hadron |
Subject: |
fs-change-smtp and draft messages |
Date: |
Tue, 14 Aug 2007 13:19:49 +0200 |
User-agent: |
Gnus/5.110006 (No Gnus v0.6) Emacs/22.0.91 (gnu/linux) |
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.