Gnus: How to archive emails according to the account they were written from? [gcc-self not working as expected]
Asked Answered
B

2

6

I have two mail accounts, [email protected] and [email protected]. I would like to archive messages I send from either one in a corresponding "sent mail" folder ([email protected]:Sent Items and [email protected]:[Google Mail]/Sent Mail).

I tried to set

(setq gnus-message-archive-group
  '(("uni" "[email protected]:Sent Items")
    ("gmail" "[email protected]:[Google Mail]/Sent Mail")
    ))

but that does not set Gcc (new messages don't have a Gcc; any solution here?). I thus went back to (setq gnus-message-archive-group "[email protected]:Sent Items") which sets Gcc correctly (for the main account [email protected]) if I open a new message in *Group* via m.

I then tried to use gcc-self via gnus-parameters to archive the sent mails correctly:

(setq gnus-parameters
       `((,(rx "[email protected]")
         (gcc-self . "[email protected]:Sent Items"))
         (,(rx "[email protected]")
         (gcc-self . "[email protected]:[Google Mail]/Sent Mail"))))

The manual (http://www.gnus.org/manual/gnus_28.html) says that if gcc-self is a string, it is simply inserted literally as Gcc header. I made the following experience: Wherever I start a new message in *Group* via C-u m (with m, Gcc is "[email protected]:Sent Items" as mentioned before), Gcc is taken to be the name the point was on in *Group* before m was hit. So if the point is on [email protected]:Drafts, Gcc will be Gcc: [email protected]:Drafts (instead of [email protected]:[Google Mail]/Sent Mail). How can this be fixed and messages archived in the corresponding sent mail folders if written via C-u m? In other words, why are the Gcc's not set correctly?

[this is on Emacs 24.3.50.1, Gnus v5.13]

Brooklyn answered 8/4, 2013 at 20:28 Comment(0)
R
5

I had exactly the same issue as you. Even though I was adding in a gcc-self parameter to be "INBOX.Sent" when I sent the message it was ending up in "nnfolder+archive:sent.YYYY-MM"

My setup is that I have a default account (home) and a secondary account (work) both imap (but not Gmail, hopefully this answer still applies)

Through a lot of trial and error I managed to get it functioning as I wanted: work emails to be saved in the work sent folder, home emails to be saved in the home sent folder.

In the gnus-parameters I simply changed my gcc-self param to gcc and it worked! However, only for the secondary address.

For the default address I set gnus-message-archive-group

A cut down of my ~/.gnus file

(setq gnus-select-method
      '(nnimap "home"
                (nnimap-address "mail.homeaddress.com")
                (nnimap-server-port 143)
                (nnimap-stream starttls)
                (nnimap-inbox "INBOX")
                 ))

(setq gnus-secondary-select-methods
      '((nnimap "work"
                (nnimap-address "mail.workaddress.com")
                (nnimap-server-port 143)
                (nnimap-stream starttls)
                (nnimap-inbox "INBOX"))))
(setq gnus-parameters
      '(
        ("work"
         (posting-style
          (address "[email protected]")
          (gcc "nnimap+work:INBOX.Sent")))))

(setq gnus-message-archive-group "nnimap:INBOX.Sent")

Notice that I don't have any posting-styles for home.

I hope this helps.

Emacs Version 24.3.1, Gnus v5.13

Resin answered 22/4, 2013 at 20:19 Comment(0)
B
0

I have encountered the same problem during my Gnus setup. I use Gmail for personal stuff and Outlook for work. My goal is to compose/reply messages using the corresponding account that I am currently working on in Gnus. Based on the suggestions from robsearles, I managed to achieve this goal using gnus-posting-styles. Here is the sample code I use.

;; Archive outgoing email in Sent folder on imap.gmail.com
(setq gnus-message-archive-method '(nnimap "imap.gmail.com")
      gnus-message-archive-group "[Gmail]/Sent Mail")

;; Set return email address based on incoming email address
(setq gnus-posting-styles
      `((".*"
        (address "[email protected]")
        (name "Foo Bar")
        ("X-Message-SMTP-Method" "smtp smtp.gmail.com 587 [email protected]")
       )
       ("^nnimap[+]outlook:.*"
       (address "[email protected]")
       (name "Foo Bar")
       ("X-Message-SMTP-Method" "smtp smtp-mail.outlook.com 587 [email protected]")
       (gcc "\"nnimap+outlook:Sent Items\"")
       )
      )
    )

The gnus-message-archive-method and gnus-message-archive-group set the default archiving behavior which archives messages to my Gmail Sent folder. The gcc tag in gnus-posting-styles instructs Gnus to archive messages to my Outlook Sent folder when I am working with the Outlook account. I also get the benefit of automatically selecting the outgoing mail server depending on the email account I am working on with the X-message-SMTP-Method tag. Outlook seems to automatically archives a message to the Sent folder whenever it is sent, so I used (gcc nil) in my actual setup to avoid duplicates. You can of course change outlook to whatever mail service you are using.

Busby answered 25/7, 2019 at 13:59 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.