From: George McNinch <gmcninch@gmail.com>
To: info-gnus-english@gnu.org
Cc: ding@gnus.org
Subject: multiple gmail accounts: smtp and expiry
Date: Sat, 14 Apr 2012 13:36:32 -0400 [thread overview]
Message-ID: <87sjg6dxlr.fsf@gmail.com> (raw)
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 <gmcninch (at) gmail.com>
| http://gmcninch.math.tufts.edu
`--<>----
next reply other threads:[~2012-04-14 17:36 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-04-14 17:36 George McNinch [this message]
2012-04-17 12:43 ` Sivaram Neelakantan
2012-04-17 13:48 ` Richard Riley
2012-04-18 15:42 ` Sivaram Neelakantan
2012-04-18 15:47 ` Richard Riley
2012-04-20 16:27 ` Sivaram Neelakantan
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=87sjg6dxlr.fsf@gmail.com \
--to=gmcninch@gmail.com \
--cc=ding@gnus.org \
--cc=info-gnus-english@gnu.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).