7

I'm able to sync my Gmail inbox, but the sent folder does not work.

This is my .mbsyncrc

IMAPStore martinstabenfeldt-remote
    Account martinstabenfeldt

MaildirStore martinstabenfeldt-local
    Path ~/.mail/martinstabenfeldt/           
    INBOX ~/.mail/martinstabenfeldt/INBOX

Channel martinstabenfeldt
    Master :martinstabenfeldt-remote:
    Slave :martinstabenfeldt-local:
    Patterns *
    # Automatically create missing mailboxes, both locally and on the server
    Create Both
    # Save the synchronization state files in the relevant directory
    SyncState *

Channel martinstabenfeldt-inbox
    Master ":martinstabenfeldt-remote:INBOX"
    Slave  ":martinstabenfeldt-local:INBOX"

Channel martinstabenfeldt-sent
    Master ":martinstabenfeldt-remote:[Gmail]/Sent Mail"
    Slave  ":martinstabenfeldt-local:sent"

This is the error I get:

$ mbsync --verbose  martinstabenfeldt-sent
Logging in...
Opening master box [Gmail]/Sent Mail...
Opening slave box sent...
Error: channel martinstabenfeldt-sent: slave sent cannot be opened.
C: 1/1  B: 1/1  M: +0/0 *0/0 #0/0  S: +0/0 *0/0 #0/0

Any idea why this fails? I've created the ~/.mail/martinstabenfeldt/sent folder. And this folder is empty.

martins
  • 9,669
  • 11
  • 57
  • 85
  • Have a look at https://delog.wordpress.com/2011/05/10/access-imap-server-from-the-command-line-using-openssl/ and tell us what the IMAP server returns when executing `tag LIST "" "*"` – Sjon Oct 03 '16 at 09:58

3 Answers3

11

Not the OP's case, but you can get this exact error message if you forgot the trailing slash in the Path configuration variable for the MaildirStore.

The man page does say the trailing slash is needed, but that's easy to overlook.

phkb
  • 143
  • 1
  • 5
6

Try Using [Google Mail] instead of [Gmail]. It should work. I believe there is Starred, Spam, Sent Mail, Important, Drafts, Bin and All Mail that will work with [Google Mail]/.

Here is my config file:

IMAPAccount gmail
Host imap.gmail.com
User <your email address>
Pass <your password>
SSLType IMAPS
CertificateFile /etc/ssl/certs/ca-certificates.crt

IMAPStore gmail-remote
Account gmail

MaildirStore gmail-local
Path ~/mail/gmail/
Inbox ~/mail/gmail/inbox

Channel gmail-default
Master :gmail-remote:
Slave  :gmail-local:
Patterns INBOX

Channel gmail-sent
Master ":gmail-remote:[Google Mail]/Sent Mail"
slave  :gmail-local:sent

Channel gmail-trash
Master :gmail-remote:"[Google Mail]/Bin"
slave  :gmail-local:trash

Channel gmail-archive
Master :gmail-remote:"[Google Mail]/All Mail"
slave  :gmail-local:all

Channel gmail-drafts
Master :gmail-remote:"[Google Mail]/Drafts"
Slave :gmail-local:drafts

# Automatically create missing mailboxes, both locally and on the server
Create slave # Only create locally for now
SyncState *

Group gmail
Channel gmail-default
Channel gmail-trash
Channel gmail-archive
Channel gmail-sent
Channel gmail-drafts

If you still have issues you could try the following config:

IMAPAccount gmail
Host imap.gmail.com
User <your email address>
Pass <your password>
SSLType IMAPS
CertificateFile /etc/ssl/certs/ca-certificates.crt

IMAPStore gmail-remote
Account gmail

MaildirStore gmail-local
Path ~/mail/gmail/
Inbox ~/mail/gmail/inbox

Channel gmail-default
Master :gmail-remote:
Slave  :gmail-local:
Patterns "[Gmail]/Sent Mail"

# Automatically create missing mailboxes, both locally and on the server
Create slave # Only create locally for now
SyncState *

Group gmail
Channel gmail-default

Once you have this run the following command: mbsync -Dmn gmail

You should see some output:

* NAMESPACE (("" "/")) NIL NIL
4 OK Success
>>> 5 LIST "" "*"
* LIST (\HasNoChildren) "/" "Deleted Items"
* LIST (\HasNoChildren) "/" "Drafts"
* LIST (\HasNoChildren) "/" "INBOX"
* LIST (\HasNoChildren) "/" "Junk"
* LIST (\HasNoChildren) "/" "Notes"
* LIST (\HasNoChildren) "/" "Personal"
* LIST (\HasNoChildren) "/" "Receipts"
* LIST (\HasNoChildren) "/" "Sent"
* LIST (\HasNoChildren) "/" "Trash"
* LIST (\HasNoChildren) "/" "Unwanted"
* LIST (\HasNoChildren) "/" "Work"
* LIST (\HasChildren \Noselect) "/" "[Google Mail]"
* LIST (\All \HasNoChildren) "/" "[Google Mail]/All Mail"
* LIST (\HasNoChildren \Trash) "/" "[Google Mail]/Bin"
* LIST (\Drafts \HasNoChildren) "/" "[Google Mail]/Drafts"
* LIST (\HasNoChildren \Important) "/" "[Google Mail]/Important"
* LIST (\HasNoChildren \Sent) "/" "[Google Mail]/Sent Mail"
* LIST (\HasNoChildren \Junk) "/" "[Google Mail]/Spam"
* LIST (\Flagged \HasNoChildren) "/" "[Google Mail]/Starred"
5 OK Success
>>> 6 LOGOUT
* BYE LOGOUT Requested
6 OK 73 good day (Success)

From here you can see what your respective remote folder names should be.

Sjon
  • 4,989
  • 6
  • 28
  • 46
Badger
  • 103
  • 1
  • 7
  • 1
    This does not provide an answer to the question. Once you have sufficient [reputation](http://stackoverflow.com/help/whats-reputation) you will be able to [comment on any post](http://stackoverflow.com/help/privileges/comment); instead, [provide answers that don't require clarification from the asker](http://meta.stackexchange.com/questions/214173/why-do-i-need-50-reputation-to-comment-what-can-i-do-instead). - [From Review](/review/low-quality-posts/12143747) – Jonathan Argentiero Apr 27 '16 at 08:17
  • I had the same issue just a day or two ago. Using [Gmail]/Sent Mail did not work. Switching to [Google Mail]/Sent Mail worked for me. So I'm not sure how else one can answer the question? – Badger Apr 27 '16 at 11:21
  • 2
    Thanks for the suggestion. I changed but that gave me this error: `Error: channel martinstabenfeldt-sent: both master [Google Mail]/Sent Mail and slave sent cannot be opened.` – martins Apr 27 '16 at 17:41
  • Can you post your complete *.mbsyncrc* ? – martins Apr 27 '16 at 17:41
0

I'm pretty sure this is caused by your quotes; instead of:

Channel martinstabenfeldt-sent
    Master ":martinstabenfeldt-remote:[Gmail]/Sent Mail"
    Slave  ":martinstabenfeldt-local:sent"

try:

Channel martinstabenfeldt-sent
    Master :martinstabenfeldt-remote:"[Gmail]/Sent Mail"
    Slave  :martinstabenfeldt-local:sent
Sjon
  • 4,989
  • 6
  • 28
  • 46
  • Thanks for the suggestion. I tried it but it does not change the error: > *Error: channel martinstabenfeldt-sent: both master [Gmail]/Sent Mail and slave sent cannot be opened.* – martins Oct 03 '16 at 08:27