6

I have two mail accounts, foo.bar@uni.edu and foo.bar@gmail.com. I would like to archive messages I send from either one in a corresponding "sent mail" folder (nnimap+foo.bar@uni.edu:Sent Items and foo.bar@gmail.com:[Google Mail]/Sent Mail).

I tried to set

(setq gnus-message-archive-group
  '(("uni" "nnimap+foo.bar@uni.edu:Sent Items")
    ("gmail" "nnimap+foo.bar@gmail.com:[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 "nnimap+foo.bar@uni.edu:Sent Items") which sets Gcc correctly (for the main account foo.bar@uni.edu) 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 "nnimap+foo.bar@uni.edu")
         (gcc-self . "nnimap+foo.bar@uni.edu:Sent Items"))
         (,(rx "nnimap+foo.bar@gmail.com")
         (gcc-self . "foo.bar@gmail.com:[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 "nnimap+foo.bar@uni.edu: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 nnimap+foo.bar@gmail.com:Drafts, Gcc will be Gcc: nnimap+foo.bar@gmail.com:Drafts (instead of foo.bar@gmail.com:[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]

Marius Hofert
  • 6,546
  • 10
  • 48
  • 102

2 Answers2

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 "me@workaddress.com")
          (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

robsearles
  • 416
  • 3
  • 3
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 "foo.bar@gmail.com")
        (name "Foo Bar")
        ("X-Message-SMTP-Method" "smtp smtp.gmail.com 587 foo.bar@gmail.com")
       )
       ("^nnimap[+]outlook:.*"
       (address "foo.bar@outlook.com")
       (name "Foo Bar")
       ("X-Message-SMTP-Method" "smtp smtp-mail.outlook.com 587 foo.bar@outlook.com")
       (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.

Knightgu
  • 181
  • 1
  • 6