[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
multiple gmail accounts: smtp and expiry
From: |
George McNinch |
Subject: |
multiple gmail accounts: smtp and expiry |
Date: |
Sat, 14 Apr 2012 13:36:32 -0400 |
User-agent: |
Gnus/5.130004 (Ma Gnus v0.4) Emacs/24.1.50 (gnu/linux) |
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
`--<>----
- multiple gmail accounts: smtp and expiry,
George McNinch <=