#!/bin/cat $Id: FAQ.Gmail.txt,v 1.92 2022/06/28 11:03:40 gilles Exp gilles $ This document is also available online at https://imapsync.lamiral.info/FAQ.d/ https://imapsync.lamiral.info/FAQ.d/FAQ.Gmail.txt ======================================================================= Imapsync tips for Gmail accounts. ======================================================================= Questions answered in this FAQ are: Q. Can I use imapsync to transfer from or to Gmail accounts? Q. Even after several syncs the number of messages differs largely between imapsync and the Gmail web interface. What can I do? Q. How many days does it take to transfer X GB? Q. What is the Gmail free maximum storage size? R. 15 GB in 2020. Need more? https://gsuite.google.com/pricing.html Q. How to synchronize from Gmail to Gmail? Q. How to synchronize from XXX to Gmail? Q. How to synchronize from Gmail to XXX? Q. I can't authenticate with Gmail via IMAP and Gmail says "Please log in via your web browser" or it says "Application-specific password required: https://support.google.com/accounts/answer/185833 (Failure)" Q. Can not open imap connection on [imap.gmail.com] Unable to connect to imap.gmail.com Q. I want to sync the Sent folder only, what is it on Gmail? Q. From Gmail to Gmail, I want to keep Categories. What can I do? Q. The context is a Gmail account at the source, but not Gmail at the destination. I want cross-duplicates, different Gmail folders/labels generating duplicate messages across folders on the destination, except for the "All Mail" folder. Q. I can't sync more than 1000 messages in each Gmail folder. What can I do? Q. What are the Gmail imap names of the folders "Sent" "Trash" "Drafts" "Junk" "Flagged" and "All"? Q. Can I transfer Gmail "Chat" messages with imapsync? Q. Can I safely use --useuid or --usecache for Gmail transfers? Q. Can I use --syncduplicates Gmail transfers? Q. Gmail does not really delete messages in folder [Gmail]/All Mail What happens? What can I do? Q. Can I use the Extension of the SEARCH command: X-GM-RAW described at https://support.google.com/mail/answer/7190?hl=en https://developers.google.com/gmail/imap_extensions#extension_of_the_search_command_x-gm-raw Q. How to avoid the [IMAP] prefix on Gmail side? Q. Does imapsync have the capability to do 2 stage authentication? Q. How to use XOAUTH2 to globally authenticate gmail users? Q. How to use XOAUTH to globally authenticate gmail users? Q. How to use a Gmail account to backup several different imap accounts? Q. How to migrate email from gmail to google apps? Now the questions again with their answers. ======================================================================= Q. Can I use imapsync to transfer from or to Gmail accounts? R. Yes. But IMAP access to a Gmail account is not allowed by default so it has to be allowed in the Gmail configuration part: -> Do not go to "Manage your Google Account" (the upper right icon with your Google face) -> Instead, go to Gmail at https://mail.google.com/ -> Click on Settings, the gear button on the upper right of Gmail. -> Click on "See all settings" at the top of the pull down menu. -> Go to the tab "Forwarding and POP/IMAP" -> Go down to "IMAP Access" -> Activate the radio button "Enable IMAP" -> Click on the button "Save changes" at the bottom of the page. That's not finished, there is also the authentication issue to consider. There are two different ways to authenticate to Gmail with Imapsync, either: 1) "App password with 2-step verification" or 2) XOauth2 ready for groups on any OS or for individual Gmail authentication on Linux. For the second one, XOauth2, see the document https://imapsync.lamiral.info/FAQ.d/FAQ.XOAUTH2.txt 1) "App password with 2-step verification" is the first way to authenticate to Gmail with Imapsync. Go to https://myaccount.google.com/security and sign in with the account you want to transfer email to or from. Go to the "Signing in to Google" part of the security page and follow the process to activate the "2-step verification" until it is ok. Then, just below "2-step verification" click on the "App passwords" and follow the instruction to get a 16 characters password, on the pull down button "Select app", choose "Other (Custom name)" and call it imapsync for example. Now use this this password to access the mailbox with imapsync. The following document details what I've just described: https://support.google.com/accounts/answer/185833?hl=en Even if Google says "Every App Password is only used once", it's false and the password can be used many times. ======================================================================= Q. Even after several syncs the number of messages differs largely between imapsync and the Gmail web interface. What can I do? R. Turned off "Conversation views" on Gmail. With "Conversation views" turned off, Gmail shows the exact message count for each folder and it matches what imapsync shows. With "Conversation views" on, a single conversation can have multiple messages and it doesn't match what imapsync presents. (Thanks to Karthik.V for this input) ======================================================================= Q. How many days does it take to transfer X GB? R. Basically it takes X days to transfer X GB per account. Gmail has usage limits per day and use throttles when they are overtaken https://support.google.com/a/answer/1071518?hl=en From the previous link: * Upload with IMAP: 500 MB per day. It's 2X days to upload X GB to Gmail, it's why I suggest to add --maxbytespersecond 20000 --maxbytesafter 1_000_000_000 for uploading messages to Gmail (should be --maxbytespersecond 5787 --maxbytesafter 500_000_000 but the higher values given work well) * Download with IMAP: 2500 MB per day. It's X/2.5 days to download X GB from Gmail, it's why I suggest to add --maxbytespersecond 40_000 --maxbytesafter 3_000_000_000 for downloading messages from Gmail (should be --maxbytespersecond 28_935 --maxbytesafter 2_500_000_000 That's empirical values that work in practice. Try upper values and see if they still work. I would be grateful if you report them to me. How Gmail says limits are reached? This is either a disconnection with "BYE Session expired, please login again" or a very small rate, less than 1 Kib/s https://imapsync.lamiral.info/FAQ.d/FAQ.Gmail.txt ======================================================================= Q. How to synchronize from Gmail to Gmail? R. Use the following example: imapsync \ --user1 account1@gmail.com \ --password1 gmailsecret1 \ --user2 account2@gmail.com \ --password2 gmailsecret2 \ --gmail1 --gmail2 Or, replacing what does --gmail1 --gmail2 (values are from imapsync 2.178): imapsync \ --host1 imap.gmail.com \ --ssl1 \ --user1 account1@gmail.com \ --password1 gmailsecret1 \ --host2 imap.gmail.com \ --ssl2 \ --user2 account2@gmail.com \ --password2 gmailsecret2 \ --maxbytespersecond 20_000 \ --maxbytesafter 1_000_000_000 \ --automap \ --maxsleep 2 \ --useheader X-Gmail-Received --useheader Message-Id \ --synclabels \ --resynclabels \ --exclude "\[Gmail\]$" \ --folderlast "[Gmail]/All Mail" With --gmail1 --gmail2 you can override the parameters that are activated by them, for example: imapsync ... --gmail1 --gmail2 --maxbytespersecond 50_000 --noautomap Explanations: --maxbytespersecond 20_000 ( 20 kBytes/s ) option is here to avoid locking or errors when imap transfers exceed Gmail maximum limit. See http://support.google.com/a/bin/answer.py?hl=en&answer=1071518 --maxbytespersecond 20_000 is not mandatory in the sense Gmail may allow you to use an upper value than 1 GBytes per 24h without disconnections. If you count well, it should be 10_000, not 20_000. --maxbytesafter 1_000_000_000 option is there because option --maxbytespersecond 20000 is unnecessarily slow if the Gmail account size is less than 1 GB. --maxsleep 2 is to avoid sleeping more than 2 seconds when the --maxbytespersecond value implies a long sleep between 2 copies. --automap is not mandatory but it's a feature to automatically map folder names based on the Gmail user configuration itself, par account. It will save manual folder names changes or the use of --regextrans2 or --f1f2 to map folder names. For example, imap folder "[Gmail]/Sent Mail" may be mapped as one of E-mails enviados Enviada Enviado Gesendet Gönderildi Inviati Sendt Skickat Verzonden etc. on both sides, host1 or host2, maybe differently, sometimes in incomprehensible alphabets, a headache for imap sysadmins. See a listing here: http://stackoverflow.com/questions/2185391/localized-gmail-imap-folders/2185548#2185548 --exclude "\[Gmail\]$" is just there to avoid a warning error when selecting this not used folder. Be aware that --gmail1 --gmail2 is a special case, it's not what --gmail1 does plus what --gmail2 does when they are not invoked together. https://imapsync.lamiral.info/FAQ.d/FAQ.Gmail.txt ======================================================================= Q. How to synchronize from XXX to Gmail? R. Use the following example: imapsync --host1 mail.oldhost.com \ --user1 my_email@oldhost.com \ --password1 passwordold \ --user2 my_email@gmail.com \ --password2 gmailsecret \ --gmail2 Or, replacing what does --gmail2 (values are from imapsync 2.178): (For Linux only because of the quotes) imapsync --host1 mail.oldhost.com \ --user1 my_email@oldhost.com \ --password1 passwordold \ --host2 imap.gmail.com \ --ssl2 \ --user2 my_email@gmail.com \ --password2 gmailsecret \ --maxbytespersecond 20_000 \ --maxbytesafter 1_000_000_000 \ --automap \ --expunge1 \ --addheader \ --maxsleep 2 \ --maxsize 35_651_584 --exclude "\[Gmail\]$" \ --regextrans2 's,\[Gmail\].,,' \ --regextrans2 's,^ +| +$,,g' --regextrans2 's,/ +| +/,/,g' --regextrans2 's/['"'"'\\^"]/_/g' --folderlast "[Gmail]/All Mail" Starting from imapsync 1.926 a --regextrans2 replacing all blanks, was: --regextrans2 "s/[ ]+/_/g" With --gmail2 you can override the parameters that are activated by them, for example: imapsync ... --gmail2 --maxbytespersecond 50_000 --noautomap --maxsleep 0 Explanations: --maxbytespersecond 20_000 ( 20 kBytes/s ) option is here to avoid locking or errors when imap transfers exceed Gmail maximum limit. See http://support.google.com/a/bin/answer.py?hl=en&answer=1071518 --maxbytespersecond 20_000 is not mandatory in the sense Gmail may allow you to use an upper value than 1 GBytes per 24h without disconnections. If you count well, it should be 10_000, not 20_000. --maxbytesafter 1_000_000_000 option is there because option --maxbytespersecond 20000 is unnecessarily slow if the Gmail account size is less than 1 GB. Counting well, it should be 500_000_000, not 1_000_000_000, but 1GB is usually ok. --maxsleep 2 is to avoid sleeping more than 2 seconds when the --maxbytespersecond value implies a long sleep between 2 copies. --maxsleep 0 cancels any imapsync bandwidth restriction given by the options --maxbytespersecond or --maxmessagespersecond It does not cancel the imap server bandwidth restrictions. --automap is optional but it will save manual folders names changes or the use of --regextrans2 or --f1f2 to map folder names. --expunge1 is optional. It deletes messages marked \Deleted on host1. Imapsync syncs messages with all their flags, Gmail takes the messages marked \Deleted but deletes or moves them just after. Option --expunge1 really removes messages marked \Deleted on host1 so they are not synced at all. The --addheader option is there because "Sent" folder messages sometimes lack the "Message-Id:" and "Received:" headers needed by imapsync to identify messages (only when --useuid is not used). So option --addheader adds a "Message-Id" header consisting of the imap UID of the message on the host1 folder, like "Message-Id: 12345@imapsync". --exclude "\[Gmail\]$" is there to avoid a small examine/select error: "Could not examine: 43 NO [NONEXISTENT] Unknown Mailbox: [Gmail] (now in authenticated state) (Failure)". --regextrans2 "s/[ ]+/_/g" is there to convert blank characters not accepted by gmail to character _ underscore. In fact only leading and trailing blank characters are problems with gmail, and also successive blanks ending with the IMAP error "NO [CANNOT] Folder contains excess whitespace (Failure)" If you want to change only leading and trailing blank characters then use the following instead On Linux/Unix: --regextrans2 "s,(/|^) +,\$1,g" --regextrans2 "s, +(/|$),\$1,g" On Windows: --regextrans2 "s,(/|^) +,$1,g" --regextrans2 "s, +(/|$),$1,g" --regextrans2 "s/[\^]/_/g" is mandatory. It converts, since not accepted by gmail, character ^ to character _ underscore. --regextrans2 's/['"'"'\\^"]/_/g' is optional. It converts characters ' or " or \ to character _ underscore. You can select folders exported to imap within the gmail preferences. Select or unselect some "System labels", depending on your needs. https://imapsync.lamiral.info/FAQ.d/FAQ.Gmail.txt ======================================================================= Q. How to synchronize from Gmail to XXX? R. Use this example: imapsync \ --user1 foo@gmail.com \ --password1 gmailsecret \ --host2 imap.example.org \ --user2 tata \ --password2 tatasecret \ --gmail1 Or, replacing what does --gmail1 (values are from imapsync 2.178): imapsync \ --host1 imap.gmail.com \ --ssl1 \ --user1 foo@gmail.com \ --password1 gmailsecret \ --host2 imap.example.org \ --user2 tata \ --password2 tatasecret \ --maxbytespersecond 40_000 \ --maxbytesafter 3_000_000_000 \ --automap \ --maxsleep 2 \ --skipcrossduplicates \ --useheader="X-Gmail-Received" \ --useheader "Message-Id" \ --regextrans2 "s,\[Gmail\].,," \ --folderlast "[Gmail]/All Mail" With --gmail1 you can override the parameters that are activated by them, for example: imapsync ... --gmail1 --maxbytespersecond 50_000 --noskipcrossduplicates --noautomap Explanations: --maxbytespersecond 40_000 ( 40 kBytes/s ) option is here to avoid locking or errors when imap transfers exceed Gmail maximum limit. See http://support.google.com/a/bin/answer.py?hl=en&answer=1071518 --maxbytespersecond 40_000 is not mandatory in the sense Gmail may allow you to use an upper value than 2 GBytes per 24h without disconnections. --useheader="X-Gmail-Received" --useheader "Message-Id" are not mandatory. I use them because I found (several years ago, it may have changed) that Gmail always adds a different header "X-Gmail-Received:" to all messages it gets. So the identification by imapsync can not fail using this header. "Message-Id" is there for safety about this Gmail rule. --automap is optional but it will save manual folder names changes or the use of --regextrans2 to map folder names. --regextrans2 "s,\[Gmail\].,," If your destination imap server doesn't like the "[Gmail]" name, get rid of this "[Gmail]" part with that. You can select folders exported to imap within the Gmail preferences, for example, you may unselect all "System labels". --skipcrossduplicates is optional but it can save Gigabytes of hard disk memory. Within imap protocol, Gmail presents Gmail labels as folders, so a message labelled "Work" "ProjectX" "Urgent" ends up in three different imap folders "Work" "ProjectX" and "Urgent" after an imap sync. Option --skipcrossduplicates prevent this behavior. An issue with --skipcrossduplicates is that the first label synced by imapsync goes to its corresponding folder but other labels are then ignored. You can choose what labels have priority by using the --folderfirst option. For example, --folderfirst "Work" will sync messages labelled "Work" before messages labelled "CanWait" or "Urgent". By default imapsync syncs folders (Gmail labels) using the classical alphanumeric order. Option --folderlast "CanWait" will sync only messages that only have the label CanWait. Option --folderlast "[Gmail]/All Mail", in conjunction with option --skipcrossduplicates will only put in "[Gmail]/All Mail" the messages that are not labelled at all. https://imapsync.lamiral.info/FAQ.d/FAQ.Gmail.txt ======================================================================= Q. I can't authenticate with Gmail via IMAP and Gmail says "Please log in via your web browser" or it says "Application-specific password required: https://support.google.com/accounts/answer/185833 (Failure)" R0. My current settings on two Gmail accounts are made with three steps 0) 1) 2) 0) Login via a web browser to the Gmail account concerned. 1) The 2-step verification is OFF https://myaccount.google.com/security?hl=en&pli=1&nlr=1#signin 2) Access for less secure apps is turned ON https://www.google.com/settings/security/lesssecureapps https://support.google.com/accounts/answer/6010255?hl=en R1. See Coert Grobbelaar solution: https://web.archive.org/web/20150906230041/http://security.stackexchange.com/questions/86404/how-do-i-interact-with-google-to-import-email-via-imapsync https://support.google.com/accounts/answer/185833 R2. I had the same issue one time (mars 2015) logging to Gmail with imapsync. The Gmail imap message error said "Please log in via your web browser" so I logged for this account via a web browser. Then, it asked me to receive a code via a mobile, I said yes, I entered the code and everything went ok on next syncs with imapsync. R1 again. Since people rarely follow links in a txt file, I reproduce Google documentation from the link https://support.google.com/accounts/answer/185833 Sign in using App Passwords An App Password is a 16-digit passcode that gives a non-Google app or device permission to access your Google Account. App Passwords can only be used with accounts that have 2-Step Verification turned on. When to use App Passwords To help keep your account secure, use "Sign in with Google" to connect apps to your Google Account. If the app you’re using doesn’t offer this option, you can either: Use App Passwords to connect to your Google Account Switch to a more secure app Create & use App Passwords Note: If you use 2-Step-Verification ( https://support.google.com/accounts/answer/185839 ) and are seeing a "password incorrect" error when trying to access your Google Account, an App Password may solve the problem. * Go to your Google Account https://myaccount.google.com/ * On the left navigation panel, choose Security. * On the "Signing in to Google" panel, choose App Passwords. If you don’t see this option: * 2-Step Verification is not set up for your account. * 2-Step Verification is set up for security keys only. * Your account is through work, school, or other organization. * You’ve turned on Advanced Protection for your account. * At the bottom, choose Select app and choose the app you’re using. * Choose Select device and choose the device you’re using. * Choose Generate. * Follow the instructions to enter the App Password. The App Password is the 16-character code in the yellow bar on your device. * Choose Done. Most of the time, you’ll only have to enter an App Password once per app or device, so don’t worry about memorizing it. ======================================================================= Q. Can not open imap connection on [imap.gmail.com]: Unable to connect to imap.gmail.com R0. It looks like this issue is related to ipv6. Both ipv4 and ipv6 protocols should work with gmail and imapsync, I test that regularly, imapsync works fine for both ipv4 and ipv6. If you disable ipv6 then disable also ipv6 resolution! The default names resolution order is to present ipv6 name resolutions first. If you know how to make ipv4 answers be taken before ipv6 then tell me. R1. First solution, run imapsync with the option --inet4: imapsync ... --inet4 R2. A second solution is to use directly gmail ipv4 ip address: imapsync ... --host1 64.233.184.108 In case it changes, get it with any command showing the imap.gmail.com name resolution, try one of those: nslookup imap.gmail.com host imap.gmail.com ping imap.gmail.com Or go to http://ping.eu/nslookup/ to get the resolution. Thanks to Chris Nolan to report, understand and fix this issue! ======================================================================= Q. I want to sync the Sent folder only, what is it on Gmail? R1. Use: imapsync ... --folder "[Gmail]/Sent Mail" R2. In fact, by configuration from the user, it can be another folder name presented in IMAP. Use --automap --dry to see this mapping. See below ======================================================================= Q. From Gmail to Gmail, I want to keep Categories. What can I do? R. First, read a document to learn how to play with Gmail Categories: https://support.google.com/mail/answer/3094499 Categories are not presented in IMAP in Gmail, so synchronizing them with imapsync requires some work. Let's say I want to synchronize the category named "Updates". 1. Create a label "Updates_L", or name it as you want. You can't create a label named "Updates" like the category name because Gmail will refuse to create it, saying it's a reserved name. 2. Select all messages in the category "Updates". To do so, you can use the string "category:updates" in the search input text located at the top of the Gmail page. Notice the case is irrelevant to the search, "category:updates" equals "Category:Updates". Gmail then announces "All 100 messages on this page are selected." It's not enough, I want all the "Updates" category messages. So, on the right of this statement, click on the text "Select all messages that match this search". Now Gmail announces "All messages in this search are selected." 3. Apply label "Updates_L" created at step 1 to all the selected messages. Gmail will present a warning and a "Confirm bulk action" button. Press "Ok". 4. Repeat steps 1 to 3 for each category you want to synchronize. 5. Transfer your mailbox to the new account with imapsync using the options --gmail1 --gmail2, the labels will be synchronized. 6. For each of the labels you made for categories, do the steps 7 to 9. As an example, I take the label "Updates_L" previously used. 7. Select all messages with the label "Updates_L". You can use the string "label:Updates_L" in the search input text located at the top of the Gmail page. Gmail then announces "All 100 messages on this page are selected." It's not enough, I want all the "updates_l" labeled messages. So, on the right of this statement, click on the text "Select all messages that match this search". Now Gmail announces "All messages in this search are selected." (does it sound similar to a previous §?) 8. Apply the category "Updates" to all the selected messages. Gmail will present a warning and a "Confirm bulk action" button. Press "Ok". If you search where are the categories: the categories are located with the labels, as if they were labels. 9. Delete the temporary label. That part is optional. Maybe one day Google will make categories optionally available in IMAP, like any other label and this trick will be obsolete. Labels can be "Show in IMAP" at https://mail.google.com/mail/u/0/#settings/labels Categories are listed there but not possibly "Show in IMAP", not yet :-) Thanks to Michael Leggett https://twitter.com/leggett for this trick. See the story at https://twitter.com/leggett/status/1484632316697739267?s=20 ======================================================================= Q. The context is a Gmail account at the source, but not Gmail at the destination. I want cross-duplicates, different Gmail folders/labels generating duplicate messages across folders on the destination, except for the "All Mail" folder. R. This behavior, different Gmail labels generating duplicates across folders except for the "All Mail" folder, is obtained with a synchronization with no --gmail1 but instead --exclude "All Mail" followed by another synchronization with --gmail1 but without --exclude "All Mail". imapsync ... --exclude "All Mail" imapsync ... --gmail1 This second sync is done to get the messages with no labels at all from the folder "All Mail", if they are some of them. Technically speaking, the first synchronization has not the option --skipcrossduplicates but the second one has the option --skipcrossduplicates and it also performs the Gmail "All Mail" folder/label at the end so only the messages that have no labels will end up in the "All Mail" destination folder (which is not Gmail, remember the context). Thanks to Mike Alexander for this suggestion. Mike also provided a patch to implement that directly in imapsync. See https://github.com/imapsync/imapsync/pull/266 (I refused it because well maintaining it will be very hard for me and I have other priorities). ======================================================================= Q. I can't sync more than 1000 messages in each Gmail folder. What can I do? R. It's a Gmail configuration feature that someone set for your Gmail account. Go to https://mail.google.com/mail/u/0/?tab=wm#settings/fwdandpop and select "Do not limit the number of messages in an IMAP folder (default)" ======================================================================= Q. What are the Gmail imap names of the folders "Sent" "Trash" "Drafts" "Junk" "Flagged" and "All"? R. By default, Gmail imap names of the folders "Sent" "Trash" "Drafts" "Junk" "Flagged" and "All" are like this: Turned on automapping folders ( use --noautomap to turn off automapping ) Host1: special [Gmail]/All Mail = \All Host1: special [Gmail]/Drafts = \Drafts Host1: special [Gmail]/Sent Mail = \Sent Host1: special [Gmail]/Spam = \Junk Host1: special [Gmail]/Starred = \Flagged Host1: special [Gmail]/Trash = \Trash Host2: special [Gmail]/All Mail = \All Host2: special [Gmail]/Bin = \Trash Host2: special [Gmail]/Drafts = \Drafts Host2: special [Gmail]/Sent Mail = \Sent Host2: special [Gmail]/Spam = \Junk Host2: special [Gmail]/Starred = \Flagged This is an excerpt from the imapsync output log done with the --automap option. This listing is located just before the folders listings. This mapping can be changed by configuration in the Gmail web interface so the result may vary. ======================================================================= Q. Can I transfer Gmail "Chat" messages with imapsync? R. No. Even if you think you can because the Chat folder is seen in IMAP, with Chat messages in them, they won't be well transferred. Chat messages are not well presented and not well transferred using the IMAP protocol. ======================================================================= Q. Can I safely use --useuid or --usecache for Gmail transfers? R. Yes, but I suggest to not use --useuid nor --usecache for Gmail transfers. Using UIDs is useless with Gmail in the case of global duplicates (duplicates across different folders). Gmail always accept a global duplicate message as a new message, giving imapsync a new UID for this message, and throw it away because it already has it. Gmail will do this at each run so imapsync will always try to copy the message, and Gmail will always accept and throw away the new copy. It ends up with no duplicates on Gmail but a waste of bandwidth and time, which is the opposite goal of --usecache implied by --useuid. ======================================================================= Q. Can I use --syncduplicates Gmail transfers? R. Yes, but Gmail will accept the new duplicate message and throw away the new copy. It ends up with no duplicates on Gmail but a waste of bandwidth and time. ======================================================================= Q. Gmail does not really delete messages in folder [Gmail]/All Mail What happens? What can I do? R. It's true and explained in Gmail documentation at https://support.google.com/mail/answer/7401?hl=en#zippy=%2Cempty-your-trash To really remove messages in folder "[Gmail]/All Mail", they have to be moved to the "Trash" folder and be deleted from "Trash". Quoting the link above (4 february 2022) ... Empty your Trash If you don't want a message to stay in your trash for 30 days, you can permanently delete it. * On your computer, go to Gmail. * On the left side of the page, click More. * Scroll to Trash. * Check the box next to messages you want to permanently delete. Then click Delete forever. * Tip: The "Delete forever" option is only available in the trash. You won’t be able to delete items permanently from the Search result view. To delete all messages in your trash, click Empty Trash now. ======================================================================= Q. Can I use the Extension of the SEARCH command: X-GM-RAW described at https://support.google.com/mail/answer/7190?hl=en https://developers.google.com/gmail/imap_extensions#extension_of_the_search_command_x-gm-raw R. Sure. Example, to search only emails with attachment and in unread state: On Unix: imapsync ... --search 'X-GM-RAW "has:attachment in:unread"' On Windows: perl imapsync ... --search "X-GM-RAW ""has:attachment in:unread""" ======================================================================= Q. How to avoid the [IMAP] prefix on Gmail side? How to stop creating folder with this prefix? Any switch we can use? e.g. [IMAP]/Archive R. No switch in imapsync since [IMAP]/ prefix is done by Gmail, it might be configurable within Gmail parameters configuration. ======================================================================= Q. Does imapsync have the capability to do 2 stage authentication? R. No, imapsync doesn't support 2 stage authentication. Reading https://support.google.com/mail/answer/1173270?hl=en it looks like it can't because imapsync uses imap protocol. So you have to follow the Google recommendation and generate an application-specific password or normal authentication or use XOAUTH or XOAUTH2. ======================================================================= Q. How to use XOAUTH2 to globally authenticate gmail users? R. Yes, but really tested on Unix systems, not sure on Windows. See: http://imapsync.lamiral.info/FAQ.d/FAQ.XOAUTH2.txt ======================================================================= Q. How to use XOAUTH to globally authenticate gmail users? R0. XOAUTH is considered obsolete and superseded by XOAUTH2 See http://imapsync.lamiral.info/FAQ.d/FAQ.XOAUTH2.txt ======================================================================= Q. How to use a Gmail account to backup several different imap accounts? R. For each account named xxx use: imapsync ... --subfolder2 xxx/xxx It syncs the account xxx under a sub-subfolder xxx/xxx. This way there is no supplementary label created on the multi-archive Gmail destination account. No labels all over the place and all original xxx sub-folders show up nested within xxx/xxx. ======================================================================= Q. How to migrate email from gmail to google apps? R. Take a look at: http://biasecurities.com/2009/02/migrate-email-from-gmail-to-google-apps/ http://www.thamtech.com/blog/2008/03/29/gmail-to-google-apps-email-migration/ ======================================================================= =======================================================================