May 18, 2018
marcelatoath
A Peek Behind the Mail Curtain
<p><b>USE IMAP TO ACCESS SOME UNIQUE FEATURES</b></p><p><i>By Libby Lin, Principal Product Manager</i></p><p>Well, we actually won’t show you how we create the magic in our big OATH consumer mail factory. But nevertheless we wanted to share how interested developers could leverage some of our unique features we offer for our Yahoo and AOL Mail customers. </p><p>To drive experiences like our travel and shopping smart views or message threading, we tag qualified mails with something we call <i>DECOS</i> and <i>THREADID</i>. While we will not indulge in explaining how exactly we use them internally, we wanted to share how they can be used and accessed through IMAP. </p><p>So let’s just look at a sample IMAP command chain. We’ll just assume that you are familiar with the IMAP protocol at this point and you know how to properly talk to an IMAP server. </p><p>So here’s how you would retrieve <i>DECO</i> and <i>THREADID</i>s for specific messages: </p><p><b><i>1. CONNECT</i></b></p><p><b> openssl s_client -crlf -connect imap.mail.yahoo.com:993</b></p><p><i><b>2. LOGIN </b></i></p><p><b> a login username password</b></p><p> a OK LOGIN completed</p><p><b><i>3. LIST FOLDERS</i></b></p><p><b> a list “” “*”</b></p><p> * LIST (\Junk \HasNoChildren) “/” “Bulk Mail”</p><p> * LIST (\Archive \HasNoChildren) “/” “Archive”</p><p> * LIST (\Drafts \HasNoChildren) “/” “Draft”</p><p> * LIST (\HasNoChildren) “/” “Inbox”</p><p> * LIST (\HasNoChildren) “/” “Notes”</p><p> * LIST (\Sent \HasNoChildren) “/” “Sent”</p><p> * LIST (\Trash \HasChildren) “/” “Trash”</p><p> * LIST (\HasNoChildren) “/” “Trash/l2”</p><p> * LIST (\HasChildren) “/” “test level 1”</p><p> * LIST (\HasNoChildren) “/” “test level 1/nestedfolder”</p><p> * LIST (\HasNoChildren) “/” “test level 1/test level 2”</p><p> * LIST (\HasNoChildren) “/” “&T2BZfXso-”</p><p> * LIST (\HasNoChildren) “/” “&gQKAqk7WWr12hA-”</p><p> a OK LIST completed</p><p><b><i>4.SELECT FOLDER</i></b></p><p><b> a select inbox</b></p><p> * 94 EXISTS</p><p> * 0 RECENT</p><p> * OK [UIDVALIDITY 1453335194] UIDs valid</p><p> * OK [UIDNEXT 40213] Predicted next UID</p><p> * FLAGS (\Answered \Deleted \Draft \Flagged \Seen $Forwarded $Junk $NotJunk)</p><p> * OK [PERMANENTFLAGS (\Answered \Deleted \Draft \Flagged \Seen $Forwarded $Junk $NotJunk)] Permanent flags</p><p> * OK [HIGHESTMODSEQ 205]</p><p> a OK [READ-WRITE] SELECT completed; now in selected state</p><p><b><i>5. SEARCH FOR UID</i></b></p><p><b> a uid search 1:*</b></p><p> * SEARCH 1 2 3 4 11 12 14 23 24 75 76 77 78 114 120 121 124 128 129 130 132 133 134 135 136 137 138 40139 40140 40141 40142 40143 40144 40145 40146 40147 40148 40149 40150 40151 40152 40153 40154 40155 40156 40157 40158 40159 40160 40161 40162 40163 40164 40165 40166 40167 40168 40172 40173 40174 40175 40176 40177 40178 40179 40182 40183 40184 40185 40186 40187 40188 40190 40191 40192 40193 40194 40195 40196 40197 40198 40199 40200 40201 40202 40203 40204 40205 40206 40207 40208 40209 40211 40212 </p><p> a OK UID SEARCH completed</p><p><b><i>6. FETCH DECOS BASED ON UID</i></b></p><p><b> a uid fetch 40212 (X-MSG-DECOS X-MSG-ID X-MSG-THREADID)</b></p><p> * 94 FETCH (UID 40212 X-MSG-THREADID “108” X-MSG-ID “ACfIowseFt7xWtj0og0L2G0T1wM” X-MSG-DECOS (“FTI” “F1” “EML”))</p><p> a OK UID FETCH completed</p>