How to fetch messages from specific label(folder) using IMAP in Gmail? - gmail

When I list folders I don't have 'snoozed' folder there.
I Googled and it seems like 'snoozed' is sort of internal label that is not available through IMAP (is it correct??). So I want to find where 'snoozed' mails are really kept.
Can I do it using fetch command for instance? How?

There is a really good explanation that this is something that it's not possible in this thread.
Pretty much the Snooze feature is implemented internally within Gmail UI and so Imap clients won't be able to replicate this behavior, therefore you won't be able to find emails snoozed when using a mail client.

Related

trigger a .sh script when a specific subject email is received

Anyway, I have a script that I want to run whenever I receive an email on gmail. And if possible a subject specific email. is such a thing possible and if so, what programs do I need to allow it.
You can't instruct gmail to trigger an external script for you. I think you've got a few basic choices. In order of increasing difficulty and complexity:
1) Configure a gmail filter to deliver your desired messages to a special folder. Write a script to poll that folder, download (or delete or mark as read) messages it finds there, and then launch your local script. Set up a cron on your local machine to run the script every few minutes. You can poll the folder with IMAP or the GMAIL API. IMAP is probably easier. This will be tricky with shell, you're better of with Python, PHP, or similar.
2) Configure a gmail filter to forward your desired messages to an address on a mail server that you control. Use procmail or similar to intercept the incoming messages and launch your script.
3) Set up an account at Mailgun and configure the emails so they get delivered there directly. (Or forward from gmail as in #2.) Configure Mailgun to launch an API request when it receives messages. Build an API handler to receive the request. Launch your process from your API handler.
I have never done it, but I guess the first thing you should do is to take a look at the Google's Gmail API...
What is the Gmail API?
The Gmail API gives you flexible, RESTful access to the user's inbox,
with a natural interface to Threads, Messages, Labels, Drafts, and
History.
It seems to fit what you want - at least, without knowing the details of what you want to do.
The Gmail API can be used in a variety of different applications,
including, typically:
Read-only mail extraction, indexing, and backup
Label management
(add/remove labels)
Automated or programmatic message sending
You can use several programming languages - maybe the trick is using your programming language of choice to write a wrapper for the .sh script... I hope this helps!

GMail IMAP API limited to first 1000

I've bee experimenting with GMail IMAP API using the gmail ruby gem and was unable to pull search results for old emails. More specifically, if I would search for emails about a year ago they would not show up in the search result. This seems consistent with the Mail app on iPhone which also uses IMAP and seems likes its impossible to retrieve old emails.
It seems like this might be related to some limit that Gmail is putting on the IMAP interface which limits it only to the first 1000 emails.
Anybody else can confirm this?
Is there a way around this?
That's settable in gmail. I don't remember whether it's a per-account of per-mailbox setting.

Listening to folder create, delete, renamed and mail flagged events in imap server?

Using IMAP IDLE it is possible to listen for new mail and delete mail events. I used node-imap module in node.js to do that. But is it possible to listen for the flag change events like mark as read, unread and also folder creation/deletion/rename events?
I read about IMAP NOTIFY extension here they specified imap client but it seems gmail is not supporting it and also in node.js I can't find anymodules that implemented this "IMAP NOTIFY". Please give any suggestion to achieve this.
As for the flag and keyword changes, yes, the IDLE extension was designed just for this purpose. Please note that Gmail does not report flag changes when in IDLE. The linked thread contains a workaround. Gmail's behaivor is completely breaindead, of course.
As for other changes, the NOTIFY extension is what you are looking for, but its support among servers is rather scarce -- only Dovecot, AFAIK. If your favorite IMAP client library doesn't offer it already, you should ask their authors.

Is passing an email list by POST rather than GET possible?

I am using the following to create an on-the-fly live updating email list for interested users on my site:
https://mail.google.com/mail/?view=cm&tf=0&fs=1&to=email#address.com&cc=blah#blah.com,another#one.com&body=test%20email&shva=1
This works great for a few emails and has been the only solution I have found for mailing lists using gmail. Please let me kow if there is a better way to do this. Gmail seems to lack functionality to do this on it's own.
So the problem:
I now have close to 500 email addresses which gives me the beautiful error
Request-URI Too Large The requested URL /mail/... is too large to process.
For obvious reasons. I was wondering if there is a way (or one could be added) to support POST variables in addition to GET variables. I tried a few tests with no luck.
Please help me as many people count on it. Thanks!
p.s. it does not have to be pretty, just function correctly
Gmail isn't designed to deal with recipient lists that long. You should look for a dedicated mailing list service - you could even use a private google groups group for it.
Remember, if you have a list that long, you'd better be prepared to deal with unsubscribe requests (unless you want your gmail account disabled :). A proper mailing list service will take care of this for you.

Setting up a MRA (fetchmail/getmail) to pull all folders from Gmail over POP/IMAP

I would like to setup fetchmail or getmail to pull email from Gmail. I would prefer it to be IMAP but I can live with POP as well. The issue I'm running into is that all these seem to want you to specify the exact list of folders you want checked (this is cleaner in IMAP than POP).
This is a hassle since I frequently change my list of folders and when I do, I don't want to have to change my configuration file to add/remove folders. When something changes, I automatically want a mbox or a maildir directory to 'show up' with the contents of my new folder. I would also prefer the mbox to have the same name as the folder on the server
The closest thing I could find was the -r option in fetchmail but that doesn't seem to do this either. I'm sure I must be missing something since every email client is able to do this and I'm hoping that that functionality lives inside the MRA and not in the MUA.
Update: I'd like to move this thread to Serverfault and I'm ok with voting to close this and migrate. Unfortunately, I dont have the rep to do it myself yet
With getmail you can use the following line in your configuration to get all your mail :
mailboxes = ("[Google Mail]/All Mail",)
With IMAP you can list the folders on the server, that way email clients can do whatever they need. In getmail it depends on how the email retrievers are written. If this configuration does not work, you can check the IMAP retriever code and write a specific one that suits your needs ;-)
my 2 cents
PS: I have no getmail installation to check if that do the trick ...
You could look into imapsync. It is designed to recursively sync up IMAP accounts. You will need an IMAP account for the destination. I have not tested it with gmail but if gmail is a well behaved IMAP server it should work.

Resources