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

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