From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.emacs.gnus.general/81986 Path: news.gmane.org!not-for-mail From: mihkel Newsgroups: gmane.emacs.gnus.general Subject: Re: Can't send message through smtp with gmail Date: Thu, 28 Jun 2012 18:03:01 +0300 Message-ID: References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: dough.gmane.org 1340895890 17395 80.91.229.3 (28 Jun 2012 15:04:50 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Thu, 28 Jun 2012 15:04:50 +0000 (UTC) Cc: ding@gnus.org To: Katsumi Yamaoka Original-X-From: ding-owner+M30256@lists.math.uh.edu Thu Jun 28 17:04:49 2012 Return-path: Envelope-to: ding-account@gmane.org Original-Received: from util0.math.uh.edu ([129.7.128.18]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1SkGGy-0000RJ-Lt for ding-account@gmane.org; Thu, 28 Jun 2012 17:04:44 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.math.uh.edu) by util0.math.uh.edu with smtp (Exim 4.63) (envelope-from ) id 1SkGFU-0004OX-K8; Thu, 28 Jun 2012 10:03:12 -0500 Original-Received: from mx2.math.uh.edu ([129.7.128.33]) by util0.math.uh.edu with esmtps (TLSv1:AES256-SHA:256) (Exim 4.63) (envelope-from ) id 1SkGFR-0004OH-RS for ding@lists.math.uh.edu; Thu, 28 Jun 2012 10:03:09 -0500 Original-Received: from quimby.gnus.org ([80.91.231.51]) by mx2.math.uh.edu with esmtps (TLSv1:AES256-SHA:256) (Exim 4.76) (envelope-from ) id 1SkGFQ-0000g2-CR for ding@lists.math.uh.edu; Thu, 28 Jun 2012 10:03:09 -0500 Original-Received: from mail-wi0-f176.google.com ([209.85.212.176]) by quimby.gnus.org with esmtp (Exim 4.72) (envelope-from ) id 1SkGFO-0007rK-O1 for ding@gnus.org; Thu, 28 Jun 2012 17:03:06 +0200 Original-Received: by wibhn17 with SMTP id hn17so122741wib.5 for ; Thu, 28 Jun 2012 08:03:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; bh=zsZegjNUTcyGTjjNa3s1ndCONi0tCpnd6T5cm63CJmw=; b=UGYNa5Yui9BUr6UFQ5fMkPSGRHbghMdAsSL09lJqi9IPy2UCc/6JJRWl+Kqq2xo7sv uh4EzsHYZDrz2OR4rRp8FWPJifK/4wWJfPRn2KX500Ba8Xo4OwCKgdy636SwGCt8OY/h PlDkJJNei4dplwqEoOK38lZ2cIrvPViJwX/Wyy3GXNOcDh+1EgPPzelaNbXgbaek06iU 0sO7zQIv/s1wSKsGNaRWkWQEeGy/N34Hsp2IoBgX0tkBD957z5CuGO7JbIouTJmF2uzR jWsQuueoXRVUYolmwB3T7hA0IgRKpG8zkWXNEtldzk9ks4Bd078FQhMJSA7LcqtehIKI MG0w== Original-Received: by 10.180.86.194 with SMTP id r2mr744915wiz.15.1340895781160; Thu, 28 Jun 2012 08:03:01 -0700 (PDT) Original-Received: by 10.194.36.136 with HTTP; Thu, 28 Jun 2012 08:03:01 -0700 (PDT) In-Reply-To: X-Spam-Score: -3.0 (---) List-ID: Precedence: bulk Xref: news.gmane.org gmane.emacs.gnus.general:81986 Archived-At: Hi and thanks for reply. On Thu, Jun 28, 2012 at 1:28 AM, Katsumi Yamaoka 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) > =A0"Run `change-smtp' in advance." > =A0(with-current-buffer smtpmail-text-buffer > =A0 =A0(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 =3D (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