Gmail's IMAP server implementation is different than most. It has the job of trying to represent a database of messages with multiple labels as IMAP mailboxes (folders) while being compatible with lots of IMAP clients, including ones that don't support IMAP keywords (Opera supports them). And, it has to do this while keeping things in sync with the mail.google.com web interface.
Because of this, the way you do actions on messages in your IMAP client (any IMAP client, not just M2) is different and something you need to get used to if you want to take full advantage of what Gmail IMAP has to offer.
First, log in to mail.google.com (if you haven't created a Gmail account yet, do so). Then, once you're logged in, turn on IMAP in Settings -> Forwarding and POP/IMAP.
Then, in Opera:
Tools (or O-Menu) -> Mail and Chat accounts -> add -> email -> next -> enter your name and your gmail address -> next -> enter your username (your gmail address) and password -> finish
Go back to "Mail and Chat accounts", select the gmail account and choose edit. On the outgoing tab, set the default encoding to UTF-8. Then, click "edit signature" and set your signature to your first name.
If you have multiple mail accounts in Opera, when using the Gmail account, right-click in the mail panel and set "Show messages from" to just the Gmail account.
Also, for each message list that you use, click the "Sent" column header twice so that its arrow is pointing down (to sort by Sent date in descending order)
Check out this article for step-by-step instructions for setup:
http://www.pcmech.com/article/setting-up-imap-enabled-gmail-in-opera-924/
If you just want a direct overview of how to use Opera's built-in mail client with Gmail IMAP, see the Gmail IMAP Action Table.
In short, you only use the "Mail for you@gmail.com" access point in Opera's mail panel. Everything else in the mail panel, you collapse, ignore and do not use, at all.
That's all there is to it. If you're happy (and you should really try to be as things sync perfectly with the web interface this way), you're done reading. If not, read on.
In Opera, when you have a filter set to "mark messages as filtered", the messages in the filter won't show in other views unless those views have "View -> Show -> Show filtered" checked. "Mark messages as filtered" is 'Hide from other=1' in index.ini in the mail folder (see Help -> About Opera for the location).
Given this info, you can close down Opera and set 'Hide from other' to 1 for the [Gmail]/Drafts, [Gmail]/Trash, [Gmail]/Spam, [Gmail]/Starred], Inbox and all your other label folders (including the "Trash" label folder) sections. You should be able to find each section by its 'name=' value. (You don't have to do this for [Gmail]/Sent if it's set as your IMAP sent folder.)
Doing this will get rid of duplicates from all those folders in all views that don't have "View -> Show -> Show filtered" checked. Since, all the views under Attachments, Labels and Mailing lists etc. have "Show filtered" checked, you'll have to uncheck it for each of those views.
The downside of this is that you won't be able to use "Show filtered" at all.
Also, be warned! You can severely mess things up if you don't edit index.ini correctly. And, backing up index.ini alone is not enough. You need to back up the whole mail folder and restore the whole mail folder if something gets messed up. Just restoring index.ini when something gets messed up will only work if nothing has changed Opera (like new messages etc.).
Note that you'll still have to use the "Mail for" IMAP access point and the Action Table mentioned above. But, see below if you're still not happy.
If you would rather just make the Gmail IMAP server behave like a normal IMAP server (so you can use Opera's built-in mail client like you would with a normal IMAP server and use all of Opera's built-in views etc), try this:
At mail.google.com:
Turn on IMAP in Settings -> Forwarding and POP/IMAP.
Turn on the Gmail Labs Advanced IMAP controls extension in Settings -> Labs.
Under "Forwarding and POP/IMAP", set auto-expunge to "Do not automatically expunge messages".
Under "Forwarding and POP/IMAP", set "When a message is expunged from the last visible IMAP folder:" to "Immediately delete the message forever".
Under "Forwarding and POP/IMAP", set "Folder Size Limits" to "Do not limit the number of messages in an IMAP folder".
Under Settings -> Labels, make sure the checkbox for "Show in IMAP" is only checked for "Sent Mail". Make sure all the others including "All Mail" are unchecked. (You can't uncheck "Inbox", which is fine.)
Goto All Mail, select all messages in it and click "move to Inbox" so that they show in the IMAP Inbox folder.
Empty the trash and unstar any messages you have as you won't be able to see these in Opera anyway.
You'll know you have things right when the only IMAP folders in the "mail for you@gmail.com" access point in Opera are [Gmail]/Sent Mail and "Inbox".
Then, things will be better in Opera and you can use All Messages/Trash for trash. And, you can use All Messages/Sent Mail for Sent (make sure the "Sent Mail" folder is set as the IMAP sent folder in the account's preferences in Opera). And, you can create filters in Opera, place messages in them and not have duplicates. And, you can use message lists, labels, searches and 'followed threads' without having duplicates. And, you can use Unread and All Messages/Received without having duplicates. And, you can even make use of All Messages/Spam for any spam messages that get by Gmail's spam blocker. And, you don't even have to look at the "mail for you@gmail.com" access point in the mail panel. You can keep it collapsed.
Now, since the IMAP spam folder is hidden from Opera with the above config, for any senders you want to be sure will not be marked as spam, just create a filter and put that sender's email address in the from field, click next and check "never send it to spam". Always apply the filter to existing messages too though.
Also, when you're using Gmail IMAP in Opera, right-click in the mail panel and set "Show messages from" to just the Gmail account.
You can create a new Gmail account to test this out on if you want (if you don't want to mess with your existing account just yet).
Note: With this configuration, the IMAP Action Table linked above, and a lot of the Gmail-specific stuff in the sections below, do not apply!
Also, you do not want to use this configuration if you also plan on using the mail.google.com interface to read your mail. You only want to use this configuration if you plan on always using Opera's built-in mail client to check your email. With this configuration, you only use the mail.google.com interface for configuring filters. (Of course, you can disregard this warning if you know what you're doing.)
Read the following sections if you want to understand more about how Gmail IMAP works (including why you get duplicates) and how Opera's built-in mail client works.
First off, here are some super basic examples of how IMAP works:
Sets or removes flags on selected messages. For example, the \Deleted flag could be set or unset on the selected messages to mark them as deleted.
Wipes out all messages that have the \Deleted flag
stored on them.
Wipes out messages with certain IDs that have the
\Deleted flag stored on them.
Copies a message from one mailbox to another.
Those are the basic commands that will be relevant for understanding Gmail IMAP.
In the Mail panel, you have the "Unread" *view* and several *access points*, which are: "All Messages", "Filters", "Followed Threads", "Labels", "Attachments", "Mailing Lists", "Mail for imap_account1", "Mail for imap_account2" "Newsgroups1?", "Newsgroups2?" and "Feeds".
Each of the access points can have multiple views themselves. For example, M2's All Messages access point has a view for Received, Outbox, Sent, Drafts, Spam and Trash.
Each View in M2 shows only messages that match a certain criteria. For example, the Received view shows received messages, the Trash view shows messages that are marked as deleted and so on.
"Mail for imap_account" access points have views for each IMAP mailbox(folder) on the server that you're subscribed to. The criteria for each of these views is basically, "Show me all messages that are in this folder on the server". This makes the "Mail for imap_account" access points the best place to manipulate messages on the server because you're dealing with raw folders kind of like you do in a webmail as opposed to dealing with filtered views. Keep this in mind as the IMAP access points are where you'll spend all of your time.
IMAP access points are also views themselves. If you click on "Mail for imap_account", you'll get a message list view that shows messages from all the IMAP folder views under the access point.
Pressing DEL or clicking the Delete button sets the \Deleted flag on the selected messages. Then, those messages will only be shown in views that have "view -> Show in -> Show Trash" set. The main view that has this is All messages/Trash.
In the All Messages/Trash view, clicking the Undelete button will remove the \Deleted flag from the selected messages. Then, they will no longer show up in the Trash view.
In the All Messages/Trash view, pressing DEL or clicking Delete for the selected
messages will UID expunge them.
Right-clicking in the mail panel and choosing Empty Trash will Expunge all
messages that have the /Deleted flag set on them.
Dragging messages from one IMAP folder view to another will move the messages.
Since there's no IMAP Move command, the messages will be copied to the target
folder and the originals will get \Deleted set on them. Then, the originals will be UID
expunged.
As an alternative to dragging, you can use the cut
and paste commands on the message list for the IMAP folder views.
If you want to copy a message from one IMAP folder to another IMAP folder, you
have to use the copy and paste commands in the message list for the IMAP folder views.
Or, you can hold down ctrl while you drag.
If you drag a message from a view under an access point that's not an IMAP access point to an IMAP folder view, it will initiate a copy and paste instead of a cut and paste. Same thing applies when you drag from an IMAP folder view under a *different* IMAP access point.
Now, some clients allow you to designate a certain IMAP folder as a trash folder so that when you press DEL on a message, it copies the message to the IMAP Trash folder, stores \Deleted
on the original and UID expunges the original.
Then, when you press DEL in the IMAP
Trash folder view it stores \Deleted on the message and UID expunges it. And, if you "Empty
Trash" for the the IMAP trash folderv view, it does that for all messages in the IMAP Trash folder. M2 doesn't allow one to do this, but you'll see it's not useful for Gmail IMAP anyway.
Now, M2 supports a Delete Permanently option (shift+DEL) that sets \Deleted on the
message AND UID expunges it. This is useful for when you just want the message gone
and don't want to have to Delete it and then go under the All Messages/Trash view to expunge
it. You'll see why this is important later.
In M2, the All Messages/Received view shows a list of messages for all your IMAP folders so
that you can easily search through all your messages. The Unread view is the same
thing except that it just shows unread messages from all your IMAP folders. (If you
have an IMAP sent folder set in M2, messages from it won't be shown in those views by default.)
In the message list for each view, you can click on the different header columns depending on how you want to sort messages. By default, M2's sorting is messed up and you should click on the "Sent" header twice (so that the arrow is pointing down) to sort by sent in descending order.
Gmail on the server basically consists of a database of messages with certain label attributes. The webmail UI then presents that to you in a nice way. This is fine, but when using IMAP, the database and the label attributes for each message have to be translated into IMAP mailboxes(folders).
For Gmail IMAP, [Gmail]/All Mail is your database off all your messages (Besides
[Gmail]/Sent Mail, [Gmail]/Trash and [Gmail]/Spam). Starred, Inbox and other IMAP
folders not under [Gmail] are your label folders.
A full physical *copy* of a message in [Gmail]/All Mail will be present in each
label folder that applies to the message.
So, if you receive a message with a subject of "Test" and apply the "zipzambam"
label to it, you'll have 3 physical copies of the message and it'll look like this under the "Mail for your_gmail_account" access point.
-[Gmail] - All Mail Test -Inbox Test -zipzambam Test
Now, in M2, since the Unread and All Messages/Received views show messages from all
IMAP folders, you're going to see each copy in their list (3 in this case).
That's just the way it is. Don't fight it and don't worry about it. For Gmail IMAP, you're not supposed to use anything under any of the non-imap access points/views (except All Messages/Drafts and All Messages/Sent in some cases). Just stick to just using the IMAP
folder views under "Mail for your_gmail_account" access point. Keep all the other views and access points collapsed and never expand them. Just pretend they're not there.
Here's an XML visualization of why you get multiple copies of messages in various M2 views like Unread and Received:
Gmail database:
<database> <message id="0" labels="INBOX, public-html, whatwg"> <subject>HTML5 rocks!</subject> </message> </database>
Database converted to IMAP mailboxes(folders):
<imap> <mailbox name="[Gmail]"> <mailbox name="All Mail"> <message id="0"> <subject>HTML5 rocks!</subject> </message> </mailbox> </mailbox> <mailbox name="INBOX"> <message id="0"> <subject>HTML5 rocks!</subject> </message> </mailbox> <mailbox name="public-html"> <message id="0"> <subject>HTML5 rocks!</subject> </message> </mailbox> <mailbox name="whatwg"> <message id="0"> <subject>HTML5 rocks!</subject> </message> </mailbox> </imap>
M2's Received view (a filter based on messages from the IMAP mailboxes)
<m2> <view name="Received"> <message from-mailbox="[Gmail]/All Mail"> <subject>HTML5 rocks!</subject> </message> <message from-mailbox="INBOX"> <subject>HTML5 rocks!</subject> </message> <message from-mailbox="public-html"> <subject>HTML5 rocks!</subject> </message> <message from-mailbox="whatwg"> <subject>HTML5 rocks!</subject> </message> </view> </m2>
As you can see, the reason you have multiple copies in various views is because the IMAP server has multiple copies. The IMAP server has multiple copies because Gmail's IMAP implementation uses a *copy* of a message in a mailbox to represent each active label on a message in the database.
But, you'll never be bothered by this since you do not use non-IMAP access points and views in M2 with Gmail IMAP.
Here's how you do things in M2 with Gmail IMAP so that your actions are
synchronized with how the Gmail webmail interface shows things:
If you want to move a message to Gmail's trash (which will remove all copies of it from other IMAP folders), drag
it (or cut and paste) from one of the IMAP folder views it's in to the [Gmail]/Trash IMAP folder view.
If you moved the message to the Trash and then want to undelete it, move it back and all the labels that were on the message should be restored (which means all the copies in all the label folders will be recreated).
If you want to mark a message as Spam (which will remove all copies), drag it (or cut and paste) from one of the IMAP folder views it's in to the [Gmail]/Spam IMAP folder view.
If you want to undo this, drag it back to where it was. If that doesn't have any effect as far as marking it as "Not Spam" after a while, you'll specifically have to drag it back to Inbox to get it marked as "Not spam". Then, you can archive it and reapply labels if needed.
To empty Gmail's trash, select all messages in the [Gmail]/Trash IMAP folder view and invoke Delete Permanently (shift + del).
You can use the same type of thing to clear [Gmail]/Spam.
To remove a label from a message, Delete permanently (shift + del) on it in the IMAP label
folder view. This doesn't really "Delete permanently". It just removes the labeled copy.
As an alternative, you can drag or cut and paste the message to [Gmail]/All Mail.
To change a label of a message, drag it from one IMAP label folder view to another (or use cut
and paste from one message list to another).
To add another label to a message, copy and paste it (or hold down ctrl while dragging) into another IMAP label folder view's message list.
In Opera 10, when you copy, you can continue pasting to multiple IMAP folder views so you can apply multiple labels without having to invoke copy each time. It basically works like copy and pasting works in Windows Explorer.
To Star a message, copy and paste it (or hold down ctrl while dragging) to the [Gmail]/Starred IMAP folder view's message list.
In the [Gmail]/Starred IMAP folder view, invoke Delete Permanently (shift + del) on it.
Remove the Inbox label from it by invoking the Delete Permanently command on it in the IMAP Inbox label folder view.
As an alternative, you can drag or cut and paste a message from the IMAP Inbox label folder view to [Gmail]/All Mail.
M2 doesn't offer an option to upload Drafts to Gmail. However, you can drag (or copy and paste in this case) from the All Messages/Drafts view to the [Gmail]/Drafts IMAP folder view.
When you send a message, Gmail automatically copies it to the [Gmail]/Sent Mail IMAP folder. You do not need to set [Gmail]/Sent as a sent folder in M2 in the account's properties. However, *if* you want M2 to automatically add contacts from [Gmail]/Sent Mail to M2's contacts panel, you can set [Gmail]/Sent Mail as your sent folder without getting an extra copy in [Gmail]/Sent Mail (Gmail seems to ignore the extra copy). This also allows the All Messages/Sent view to contain the full list of sent
messages that are on the Gmail server. Only do these things if you really really want to.
If you have a message with no labels, it'll only be in [Gmail]/All Mail IMAP folder. If you want to delete it, drag it to the [Gmail]/Trash IMAP folder view. If you want to add a label to it, copy and paste it to an IMAP label folder view like 'Inbox'.
In some of the situations above (like moving to Gmail's trash), you can copy and paste to the [Gmail]/Trash IMAP folder view instead of dragging(cutting and pasting) and the Gmail server will do the same thing. This will allow you to drag from the Unread or All Messages/Received views to perform an action like moving a message to Gmail's trash. But, that's not recommended and you should stick to dragging(cutting and pasting) from one IMAP folder view to another and leave non-IMAP access points and views alone.
Instead of doing Delete Permanently (shift + del) in the [Gmail]/Trash IMAP folder view for example,
you can also use just Delete. However, then, you have to empty M2's All Messages/Trash view.
This is why you use Delete Permanently so you don't have to do 2 steps. For Gmail IMAP
accounts, by default, Thunderbird makes DEL work like Delete Permanently specifically for this reason.
Most of the time, all you'll be doing is:
Opening messages, dragging them to the [Gmail]/Trash IMAP folder view and invoking Delete Permanently on them in [Gmail]/Trash.
Now, since the [Gmail]/Spam IMAP folder can contain nasty and perhaps unsafe messages, if you don't have View (the button on the mail toolbar) -> display -> "Block external embeds" checked (it's checked by default), you should set view -> display -> "list only" for message lists if you're going to be viewing the [Gmail]/Spam IMAP folder, Unread or All Messages/Received views. That way, the body of a spam message doesn't load unless you choose to open the message. (Same thing applies for all other views that might have spam messages in them.)
After you permanently delete messages from [Gmail]/Trash (or another folder when
removing a label) for example, the [Gmail]/All Mail IMAP folder view (and IMAP label folders that *had* copies of the message) won't be updated with the changes (like the unread count next to the IMAP folder view) until you either click on the IMAP folder to select it or the next sync. If this bugs you, just click check/send after you perform an action. That will sync things so that the copies disappear from all the other views faster.
If you drag a message to [Gmail] while it's collapsed, just hold over it for a second
or two and it'll expand so that you can continue dragging to the IMAP folders.
First, here are a few pics to show what the mail panel looks like. In the Gmail account used for the following pics, there is only 1 message in database. But, it has "INBOX", "Label1?", "Label2?", and "Label3?" labels applied to it.
This is a great example stressing how important it is to ignore and collapse all the access points except the IMAP account access point.
Don't use this view with Gmail IMAP. Keep it collapsed.
Don't use this view with Gmail IMAP. Keep it collapsed.
imap_access_point_top_view.png
As you can see, besides the original copy of the message that appears in the [Gmail]/All Mail IMAP folder view, there's a copy of the message in each IMAP label folder view that applies to the message. In the case of views like All Messages/Received, Unread and the IMAP access point top view, the copies for the other IMAP folder views will show in the message list also. But, don't worry about those message lists as you don't use Unread and All Messages/Received with Gmail IMAP and only use the IMAP access point top view for searching the entire IMAP account with the quick find field.
move_to_trash1.png (dragging)
move_to_trash2.png
move_to_trash3.png
empty1.png
empty2.png
empty3.png
empty4.png