Gnus development mailing list
 help / color / mirror / Atom feed
From: mihkel <turakas@gmail.com>
To: Katsumi Yamaoka <yamaoka@jpl.org>
Cc: ding@gnus.org
Subject: Re: Can't send message through smtp with gmail
Date: Thu, 28 Jun 2012 18:03:01 +0300	[thread overview]
Message-ID: <CAKB1TLqkybcKFCMRFUwht1kx8k3xQYUEtL9WFG41vwHsj1uxWg@mail.gmail.com> (raw)
In-Reply-To: <b4m8vf8z8wn.fsf@jpl.org>

Hi and thanks for reply.

On Thu, Jun 28, 2012 at 1:28 AM, Katsumi Yamaoka <yamaoka@jpl.org> wrote:
> (smtpmail-via-smtp RECIPIENT SMTPMAIL-TEXT-BUFFER &optional
> ASK-FOR-PASSWORD)
>
> How about replacing those `(defvar ...' and `(defun ...' with
> the defadvice form as follows rather than redefining the function?
>
> (defadvice smtpmail-via-smtp (before change-smtp activate)
>  "Run `change-smtp' in advance."
>  (with-current-buffer smtpmail-text-buffer
>    (change-smtp)))
>
> This is essentially the same, but you don't have to care
> the arguments spec change.

I changed these two defvar and defun with defadvice as you suggested.
Now when I send a message gnus asks for a SMTP user name for
smtp.gmail.com. When I enter one, then all messages go through this
smtp account. I have this snippet for changing smtp server according
to "from" filed.


;; Change smtp server according to "from" field
(defun change-smtp ()
  "Change the SMTP server according to the current from line."
  (save-excursion
    (loop with from = (save-restriction
			(message-narrow-to-headers)
                        (message-fetch-field "from"))
          for (acc-type address . auth-spec) in smtp-accounts
          when (string-match address from)
          do (cond
              ((eql acc-type 'plain)
               (return (apply 'set-smtp-plain auth-spec)))
              ((eql acc-type 'ssl)
               (return (apply 'set-smtp-ssl auth-spec)))
              (t (error "Unrecognized SMTP account type: '%s'." acc-type)))
          finally (error "Cannot interfere SMTP information."))))

Does the defadvice code change mentioned above break this function? I
really have to ask you to bear with me, since I'm not a programmer...
just a emacs user :)


mihkel



  reply	other threads:[~2012-06-28 15:03 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-06-27 10:25 mihkel
2012-06-27 22:28 ` Katsumi Yamaoka
2012-06-28 15:03   ` mihkel [this message]
2012-06-28 17:40     ` Richard Riley
2012-06-28 20:45       ` mihkel
2012-06-28 23:47         ` Richard Riley
2012-06-29  6:46           ` mihkel
2012-06-29  9:29             ` Richard Riley

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=CAKB1TLqkybcKFCMRFUwht1kx8k3xQYUEtL9WFG41vwHsj1uxWg@mail.gmail.com \
    --to=turakas@gmail.com \
    --cc=ding@gnus.org \
    --cc=yamaoka@jpl.org \
    /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).