From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.emacs.gnus.general/81760 Path: news.gmane.org!not-for-mail From: George McNinch Newsgroups: gmane.emacs.gnus.user,gmane.emacs.gnus.general Subject: multiple gmail accounts: smtp and expiry Date: Sat, 14 Apr 2012 13:36:32 -0400 Message-ID: <87sjg6dxlr.fsf@gmail.com> Reply-To: George McNinch NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Trace: dough.gmane.org 1334425035 11302 80.91.229.3 (14 Apr 2012 17:37:15 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sat, 14 Apr 2012 17:37:15 +0000 (UTC) Cc: ding@gnus.org To: info-gnus-english@gnu.org Original-X-From: info-gnus-english-bounces+gegu-info-gnus-english=m.gmane.org@gnu.org Sat Apr 14 19:37:14 2012 Return-path: Envelope-to: gegu-info-gnus-english@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1SJ6uO-0005wL-2M for gegu-info-gnus-english@m.gmane.org; Sat, 14 Apr 2012 19:37:12 +0200 Original-Received: from localhost ([::1]:33404 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SJ6uN-0008TT-CJ for gegu-info-gnus-english@m.gmane.org; Sat, 14 Apr 2012 13:37:11 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:42537) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SJ6uL-0008T5-0m for info-gnus-english@gnu.org; Sat, 14 Apr 2012 13:37:10 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SJ6uI-0008BB-Nw for info-gnus-english@gnu.org; Sat, 14 Apr 2012 13:37:08 -0400 Original-Received: from plane.gmane.org ([80.91.229.3]:54369) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SJ6uI-0008B7-D1 for info-gnus-english@gnu.org; Sat, 14 Apr 2012 13:37:06 -0400 Original-Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1SJ6uD-0005px-QR for info-gnus-english@gnu.org; Sat, 14 Apr 2012 19:37:01 +0200 Original-Received: from 209-6-122-78.c3-0.arl-ubr1.sbo-arl.ma.cable.rcn.com ([209.6.122.78]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sat, 14 Apr 2012 19:37:01 +0200 Original-Received: from gmcninch by 209-6-122-78.c3-0.arl-ubr1.sbo-arl.ma.cable.rcn.com with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sat, 14 Apr 2012 19:37:01 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 124 Original-X-Complaints-To: usenet@dough.gmane.org X-Gmane-NNTP-Posting-Host: 209-6-122-78.c3-0.arl-ubr1.sbo-arl.ma.cable.rcn.com User-Mail-Address: gmcninch@gmail.com User-Full-Name: George McNinch X-SMTP-User: gmcninch User-Agent: Gnus/5.130004 (Ma Gnus v0.4) Emacs/24.1.50 (gnu/linux) Cancel-Lock: sha1:W17YyzXaJurFZAch6LJQBqZOZNg= X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 80.91.229.3 X-BeenThere: info-gnus-english@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Announcements and discussions for GNUS, the GNU Emacs Usenet newsreader \(in English\)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: info-gnus-english-bounces+gegu-info-gnus-english=m.gmane.org@gnu.org Original-Sender: info-gnus-english-bounces+gegu-info-gnus-english=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.gnus.user:15430 gmane.emacs.gnus.general:81760 Archived-At: Hi, To the extent that this is useful, I thought I'd share some idea(s)/solution(s) to issues related to smtp and expiry for multiple gmail accounts in gnus. * expiry I want expired mail from a gmail account to expire to the "correct" [GMail]/Trash folder(s) for the account. After some pondering, the following seems to work. I'd be interested in alternate suggestions, though. Suppose that I have two gnus imap groups corresponding to gmail accounts: nnimap+gmail1 nnimap+gmail2 Use the following to create the per-group "expiry targets". ;---------------------------------------- (setq gm-gmail1-expiry-targets (list (from ".*" "nnimap+gmail1:[Gmail]/Trash")) (setq gm-gmail2-expiry-targets (list (from ".*" "nnimap+gmail2:[Gmail]/Trash")) (defun gm-gmail1-expiry-target-function (group) (setq nnmail-fancy-expiry-targets gm-gmail1-expiry-targets) (nnmail-fancy-expiry-target group)) (defun gm-gmail2-expiry-target-function (group) (setq nnmail-fancy-expiry-targets gm-gmail2-expiry-targets) (nnmail-fancy-expiry-target group)) ;---------------------------------------- Now use gnus-parameters (or group parameters, or topic parameters) to connect the expiry functions: ;---------------------------------------- (setq gnus-parameters '( ("nnimap\\+gmail1.*" (expiry-target . gm-gmail1-expiry-target-function) ) ("nnimap\\+gmail2.*" (expiry-target . gm-gmail2-expiry-target-function) ) )) ;---------------------------------------- I guess my feeling is that it might be better (??!) if nnmail-fancy-expiry-target(s) could also qualify expiry targets based on the value of group, rather than just based data found in the header of the article. But this might be unwieldy for reasons I haven't thought of...and anyhow the above seems to do the job. * smtp I wanted to be able to adjust the smtp-user via gnus-posting-styles -- e.g. so that "sent" mail automatically ends up in the [Gmail]/Sent folder of the correct gmail account. One solution is to adapt some code found here http://emacswiki.org/emacs/MultipleSMTPAccounts as follows. ;---------------------------------------- (eval-after-load "smtpmail" '(progn (defun smtpmail-get-and-delete-smtp-user-from-header () "Find header field X-SMTP-User and if found return value as string and delete header field. If a header field of this name doesn't exist, return nil." (save-excursion (goto-char (point-min)) (save-match-data (let ((smtp-server)) (loop until (or (eobp) (looking-at "^[ \t]*$")) if (looking-at "X-SMTP-User[ \t]*:[ \t]*\\(.*?\\)[ \t]*\n") return (prog1 (match-string 1) (replace-match "")) else do (forward-line 1)))))) (defadvice smtpmail-via-smtp (around set-smtp-user-from-header activate) (let ((smtpmail-smtp-user (or (smtpmail-get-and-delete-smtp-user-from-header) smtpmail-smtp-user))) ad-do-it )))) ;---------------------------------------- Now just do something like (setq gnus-posting-styles '( ("gmail1" ("X-SMTP-User" "gmail1-user") ) ("gmail2" ("X-SMTP-User" "gmail2-user") ) ) ) (or add the relevant lines to existing defn of gnus-posting-styles...) to insert "X-SMTP-User" headers temporarily in the mail for consumption by smtpmail-via-smtp when sending the mail. best, george -- ,--<>---- | George McNinch | http://gmcninch.math.tufts.edu `--<>----