Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Find Gmail url-IDs via IMAP

Tags:

gmail

imap

One of my favourite features of Gmail is the ability to bookmark urls to certain messages like this:

https://mail.google.com/mail/#all/124c8f386d41fd3a

What I would like to do is write a script that accesses my Gmail account via IMAP and creates an HTML page with links like the above to each message I am interested in.

However, it seems there is no way to find the "124c8f386d41fd3a" ID from the IMAP envelope or UUID properties. All the message-ids and uuids I am finding are of a different format and can't be used to produce valid links to my inbox.

Does anybody know how to find those url-IDs in IMAP?

-- Felix Geisendörfer aka the_undefined

PS: I am using Ruby and my previous attempts included:

imap.fetch(message_id, "UID") imap.fetch(message_id, "ENVELOPE") imap.fetch(message_id, ...) 

I tried all properties listed for FetchData in the ruby imap docs

like image 963
Felix Geisendörfer Avatar asked Nov 06 '09 12:11

Felix Geisendörfer


People also ask

How do you find your Gmail URL?

Right click with your mouse inside the visble area of the web-page somehwhere. A context menu should appear, select "view page source". Alternativeley just type ctrl-u. A completely new browser tab will open and in the address bar of this new tab you can see the URL that you are looking for.

Can Gmail detect IMAP?

When you use IMAP, you can read your Gmail messages on multiple devices, and messages are synced in real time. You can also read Gmail messages using POP.

Does Gmail use IMAP or POP?

For non-Gmail clients, Gmail supports the standard IMAP, POP, and SMTP protocols. The Gmail IMAP, POP, and SMTP servers have been extended to support authorization via the industry-standard OAuth 2.0 protocol.


2 Answers

Gmail provides an attribute: X-GM-THRID for thread id.

You can use imap fetch function for getting the thread id.

Also see the documentation here.

like image 130
Vivek Goel Avatar answered Sep 19 '22 20:09

Vivek Goel


Found something. May be someone need. I don't know how to use ruby, I want use php, but don't know how to extend standart imap functions in php.

openssl s_client -crlf -connect imap.gmail.com:993 . login username password . select inbox . FETCH 1 (X-GM-THRID) 

you'll get something like this * 1 FETCH (X-GM-THRID 1327644190303473294) next you need to convert it from decimal to hexadecimal value:

<?php echo dechex(1327644190303473294); ?> //return 126cbd5b5f264e8e 
like image 29
Shkur Avatar answered Sep 17 '22 20:09

Shkur