<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title>Gmail – Yeri Tiete</title>
    <link>https://yeri.be/tag/gmail/</link>
    <description>Yeri Tiete&#39;s blog</description>
    <language>en</language>
    <copyright>© Yeri Tiete</copyright>
    <lastBuildDate>Tue, 03 Feb 2015 11:53:20 +0100</lastBuildDate>
    <atom:link href="https://yeri.be/tag/gmail/index.xml" rel="self" type="application/rss+xml" />
    
    <item>
      <title>Courier IMAP and auto deleting trash after 7 days</title>
      <link>https://yeri.be/courier-imap-and-auto-deleting-trash-after-7-days/</link>
      <pubDate>Tue, 03 Feb 2015 11:53:20 +0100</pubDate>
      <author>Yeri Tiete</author>
      <guid isPermaLink="true">https://yeri.be/courier-imap-and-auto-deleting-trash-after-7-days/</guid>
      <description>&lt;p&gt;E-mails that had been deleted for over 7 days were automatically removed from the IMAP server. E-mail date was ignored (ie the mail could have been from 2010; the actual time in &amp;ldquo;Trash&amp;rdquo; counted). This didn&amp;rsquo;t happen to other folders (Sent, Archive, Spam). This recently happened and hadn&amp;rsquo;t happened before.&lt;/p&gt;&#xA;&lt;p&gt;I had to restore my trash folder from backups every 7 days (yay for &lt;a href=&#34;http://www.nongnu.org/rdiff-backup/&#34; target=&#34;_blank&#34;&gt;rdiff-backup&lt;/a&gt;).&lt;/p&gt;&#xA;&lt;p&gt;It took me a while to figure it out&amp;hellip; The problem first appeared in October, right after several big changes:&lt;/p&gt;</description>
      <content:encoded><![CDATA[<p>E-mails that had been deleted for over 7 days were automatically removed from the IMAP server. E-mail date was ignored (ie the mail could have been from 2010; the actual time in &ldquo;Trash&rdquo; counted). This didn&rsquo;t happen to other folders (Sent, Archive, Spam). This recently happened and hadn&rsquo;t happened before.</p>
<p>I had to restore my trash folder from backups every 7 days (yay for <a href="http://www.nongnu.org/rdiff-backup/" target="_blank">rdiff-backup</a>).</p>
<p>It took me a while to figure it out&hellip; The problem first appeared in October, right after several big changes:</p>
<ul>
	<li>Yosemite update</li>
	<li>Airmail to <a href="http://airmailapp.com/" target="_blank">Airmail 2</a> update (I was <a href="https://twitter.com/Tuinslak/status/543457760525180929" target="_blank">convinced this was the root cause</a>, looking at my clients instead of the server)</li>
	<li>Android 5.0.x</li>
	<li>Android Email app sunset, changes to GMail app</li>
	<li>IPv6 working decently at home after updating my <a href="https://yeri.be/connect-different-lans-over-openvpn">RPi</a> to <a href="http://en.avm.de/" target="_blank">Fritzbox</a> devices.</li>
	<li>Random connection errors in GMail app (this was due to misconfigured DNS in the GMail app and causing IPv6 catch all to redirect to the webserver instead of the mailserver. It didn't happen consistently because over mobile (4G &amp; lower) there is no IPv6 and at home is randomly falls back to IPv4 as well. IPv4 DNS was well configured.</li>
	<li>Moving my ~100.000 deleted e-mails from "Deleted Items" (OS X Mail default) to "Trash" (Android &amp; Courier default) to stop having to move them manually from one folder to the other every so often. =&gt; this was eventually the cause but I didn't realize.</li>
</ul>
Being convinced it was most likely Airmail 2 and very maybe Android I had been looking in that direction.
<p>Debugging was also extremely slow as I had to wait 7 days before being able to check if the changes I made helped anything.</p>
<p>I eventually figured out that it was not Airmail when I rebuild my whole mail database and it defaulted back to putting my deleted mails into the Archive folder instead of Trash. Archive mails were kept over 7 days, but items in Trash still removed.</p>
<p>That&rsquo;s when I started looking at Courier IMAP config: <code>/etc/courier/imapd</code> (and not <code>imapd-ssl</code>).</p>
<p>There&rsquo;s an option that says:</p>
<pre>##NAME: IMAP_EMPTYTRASH:0
#
# The following setting is optional, and causes messages from the given
# folder to be automatically deleted after the given number of days.
# IMAP_EMPTYTRASH is a comma-separated list of folder:days.  The default
# setting, below, purges 7 day old messages from the Trash folder.
# Another useful setting would be:
#  
# IMAP_EMPTYTRASH=Trash:7,Sent:30
#
# This would also delete messages from the Sent folder (presumably copies
# of sent mail) after 30 days.  This is a global setting that is applied to
# every mail account, and is probably useful in a controlled, corporate
# environment.
#
# Important: the purging is controlled by CTIME, not MTIME (the file time
# as shown by ls).  It is perfectly ordinary to see stuff in Trash that's
# a year old.  That's the file modification time, MTIME, that's displayed.
# This is generally when the message was originally delivered to this
# mailbox.  Purging is controlled by a different timestamp, CTIME, which is
# changed when the file is moved to the Trash folder (and at other times too).
#
# You might want to disable this setting in certain situations - it results
# in a stat() of every file in each folder, at login and logout.
#
IMAP_EMPTYTRASH=Trash:7</pre>
<p>Comment out that last line, and restart courier-imap(-ssl)&hellip; Simple as that.</p>
<p>This solved my issue.</p>
<p>I&rsquo;m not sure when that config change happened (Debian update?) and I do not know who at Courier thought it was a good idea &hellip;. But sheesh.</p>
]]></content:encoded>
      <category>apple</category><category>errors</category><category>linux</category><category>networking</category><category>software</category>
      <category>gmail</category><category>imap</category><category>mac os x</category><category>mail</category>
    </item>
    
    <item>
      <title>Gmail (&amp; Google Apps) &amp; IPv6</title>
      <link>https://yeri.be/gmail-google-apps-ipv6/</link>
      <pubDate>Wed, 18 Jun 2014 13:02:56 +0200</pubDate>
      <author>Yeri Tiete</author>
      <guid isPermaLink="true">https://yeri.be/gmail-google-apps-ipv6/</guid>
      <description>&lt;p&gt;It seems that &lt;a href=&#34;https://support.google.com/mail/answer/81126?p=ipv6_authentication_error&amp;amp;rd=1#authentication&#34; target=&#34;_blank&#34;&gt;Google&amp;rsquo;s anti spam measurement&lt;/a&gt; for IPv6 is basically checking if the IP has a reverse DNS. If not, reject the e-mail:&lt;/p&gt;&#xA;&lt;pre&gt;This is the mail system at host rootspirit.com.&#xA;&#xA;I&#39;m sorry to have to inform you that your message could not&#xA;be delivered to one or more recipients. It&#39;s attached below.&#xA;&#xA;For further assistance, please send mail to postmaster.&#xA;&#xA;If you do so, please include this problem report. You can&#xA;delete your own text from the attached returned message.&#xA;&#xA;The mail system&#xA;&#xA;&amp;lt;xxx@gmail.com&amp;gt;: host&#xA;gmail-smtp-in.l.google.com[2a00:1450:4013:c01::1b] said: 550-5.7.1&#xA;[2001:1af8:3100:a00a:21::1010 12] Our system has detected that&#xA;550-5.7.1 &lt;strong&gt;this message is likely unsolicited mail&lt;/strong&gt;. To reduce the amount&#xA;of spam 550-5.7.1 sent to Gmail, this message has been blocked.&#xA;Please visit 550-5.7.1 http://support.google.com/mail/bin/answer.py?hl=en&amp;amp;answer=188131 for 550 5.7.1 more information. df5si15766518wjb.42 - gsmtp (in reply to end of DATA command)&lt;/pre&gt;&#xA;&lt;p&gt;There is no difference if the mail is a one word e-mail or a wall of text that crits over 9000.&lt;/p&gt;</description>
      <content:encoded><![CDATA[<p>It seems that <a href="https://support.google.com/mail/answer/81126?p=ipv6_authentication_error&amp;rd=1#authentication" target="_blank">Google&rsquo;s anti spam measurement</a> for IPv6 is basically checking if the IP has a reverse DNS. If not, reject the e-mail:</p>
<pre>This is the mail system at host rootspirit.com.

I'm sorry to have to inform you that your message could not
be delivered to one or more recipients. It's attached below.

For further assistance, please send mail to postmaster.

If you do so, please include this problem report. You can
delete your own text from the attached returned message.

The mail system

&lt;xxx@gmail.com&gt;: host
gmail-smtp-in.l.google.com[2a00:1450:4013:c01::1b] said: 550-5.7.1
[2001:1af8:3100:a00a:21::1010 12] Our system has detected that
550-5.7.1 <strong>this message is likely unsolicited mail</strong>. To reduce the amount
of spam 550-5.7.1 sent to Gmail, this message has been blocked.
Please visit 550-5.7.1 http://support.google.com/mail/bin/answer.py?hl=en&amp;answer=188131 for 550 5.7.1 more information. df5si15766518wjb.42 - gsmtp (in reply to end of DATA command)</pre>
<p>There is no difference if the mail is a one word e-mail or a wall of text that crits over 9000.</p>
<p>The easiest way to bypass this silly check is to set up a rDNS (reverse DNS or PTR) for all your IPv6 addresses on the mail server. If you do not have this set, Google will flag all your mails over IPv6 as spam.</p>
<p>If you run <code>dig -x &lt;IPv6 address&gt;</code> you can find out if it&rsquo;s set (answer section, after &ldquo;IN PTR&rdquo;):</p>
<pre># dig -x 2001:1af8:3100:a00a:21::1010

; < <>> DiG 9.8.4-rpz2+rl005.12-P1 < <>> -x 2001:1af8:3100:a00a:21::1010
;; global options: +cmd
;; Got answer:
;; ->>HEADER< <- opcode: QUERY, status: NOERROR, id: 30041
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 13, ADDITIONAL: 0

;; QUESTION SECTION:
;0.1.0.1.0.0.0.0.0.0.0.0.1.2.0.0.a.0.0.a.0.0.1.3.8.f.a.1.1.0.0.2.ip6.arpa. IN PTR

;; ANSWER SECTION:
0.1.0.1.0.0.0.0.0.0.0.0.1.2.0.0.a.0.0.a.0.0.1.3.8.f.a.1.1.0.0.2.ip6.arpa. 21599	IN PTR mail.rootspirit.com.</pre>
<p><a href="http://tanguy.ortolo.eu/blog/article109/google-ipv6-smtp-restrictions" target="_blank">Here</a> is a work around if you cannot set rDNS. This still allows Google to send mail to you, using IPv6. The downside is that you&rsquo;ll have to do this for ALL Google Apps domains you send e-mail to. Good luck.</pre></p>
]]></content:encoded>
      <category>google</category><category>linux</category><category>networking</category>
      <category>gmail</category><category>ipv6</category>
    </item>
    
    <item>
      <title>Gmail spam &#34;mark-as-read&#34;</title>
      <link>https://yeri.be/gmail-spam-mark-as-read/</link>
      <pubDate>Mon, 21 Sep 2009 22:49:33 +0200</pubDate>
      <author>Yeri Tiete</author>
      <guid isPermaLink="true">https://yeri.be/gmail-spam-mark-as-read/</guid>
      <description>&lt;p&gt;Google changed their Mailbox names (from Google Mail, to Gmail) so &lt;a href=&#34;https://static.yeri.be/2009/09/gmail_spamreader_v0.03.phps&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;here&lt;/a&gt; is the update from my previous &lt;a href=&#34;https://yeri.be/imapgmail-mark-as-read/&#34;&gt;php script I made a few years ago&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;em&gt;Edit:&lt;/em&gt; Gmail reverted back to the previous version (imap folders were &amp;ldquo;Google Mail&amp;rdquo;, changed to &amp;ldquo;Gmail&amp;rdquo; yesterday and today). To version v0.03 won&amp;rsquo;t work anymore. I&amp;rsquo;m guessing this was a temporary change to implement their exchange/push-support.&lt;/p&gt;</description>
      <content:encoded><![CDATA[<p>Google changed their Mailbox names (from Google Mail, to Gmail) so <a href="https://static.yeri.be/2009/09/gmail_spamreader_v0.03.phps" target="_blank" rel="noopener">here</a> is the update from my previous <a href="https://yeri.be/imapgmail-mark-as-read/">php script I made a few years ago</a>.</p>
<p><em>Edit:</em> Gmail reverted back to the previous version (imap folders were &ldquo;Google Mail&rdquo;, changed to &ldquo;Gmail&rdquo; yesterday and today). To version v0.03 won&rsquo;t work anymore. I&rsquo;m guessing this was a temporary change to implement their exchange/push-support.</p>
]]></content:encoded>
      <category>software</category>
      <category>gmail</category><category>imap</category><category>spam</category>
    </item>
    
    <item>
      <title>Damn You Google !</title>
      <link>https://yeri.be/damn-you-google/</link>
      <pubDate>Wed, 11 Feb 2009 17:38:39 +0100</pubDate>
      <author>Yeri Tiete</author>
      <guid isPermaLink="true">https://yeri.be/damn-you-google/</guid>
      <description>&lt;p style=&#34;text-align: center;&#34;&gt;&lt;img class=&#34;size-full wp-image-696 alignnone&#34; title=&#34;GMail Attachment Offline&#34; src=&#34;https://static.yeri.be/2009/02/gmailattachmentoffline.png&#34; alt=&#34;GMail Attachment Offline&#34; width=&#34;500&#34; height=&#34;250&#34; /&gt;&lt;/p&gt;&#xA;&lt;p style=&#34;text-align: left;&#34;&gt;I need it now! :(&lt;/p&gt;</description>
      <content:encoded><![CDATA[<p style="text-align: center;"><img class="size-full wp-image-696 alignnone" title="GMail Attachment Offline" src="https://static.yeri.be/2009/02/gmailattachmentoffline.png" alt="GMail Attachment Offline" width="500" height="250" /></p>
<p style="text-align: left;">I need it now! :(</p>
]]></content:encoded>
      <category>errors</category><category>google</category>
      <category>gmail</category><category>offline</category>
    </item>
    
    <item>
      <title>Imap/Gmail mark as read</title>
      <link>https://yeri.be/imapgmail-mark-as-read/</link>
      <pubDate>Fri, 31 Oct 2008 02:38:51 +0100</pubDate>
      <author>Yeri Tiete</author>
      <guid isPermaLink="true">https://yeri.be/imapgmail-mark-as-read/</guid>
      <description>&lt;p&gt;I&amp;rsquo;ve &amp;ldquo;updated&amp;rdquo; my &lt;a href=&#34;https://yeri.be/gmail-automatic-mark-spam-as-read/&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;previous php&lt;/a&gt;-app.&lt;/p&gt;&#xA;&lt;p&gt;Since today I ended up getting this error:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;Warning: imap_open&lt;span class=&#34;o&#34;&gt;()&lt;/span&gt;: Couldn&lt;span class=&#34;err&#34;&gt;&amp;#39;&lt;/span&gt;t open stream &lt;span class=&#34;o&#34;&gt;{&lt;/span&gt;imap.gmail.com:993/imap/ssl&lt;span class=&#34;o&#34;&gt;}[&lt;/span&gt;Google Mail&lt;span class=&#34;o&#34;&gt;]&lt;/span&gt;/Spam in /home/yeri/.gmail.php on line &lt;span class=&#34;m&#34;&gt;30&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;Certificate failure &lt;span class=&#34;k&#34;&gt;for&lt;/span&gt; imap.gmail.com: unable to get &lt;span class=&#34;nb&#34;&gt;local&lt;/span&gt; issuer certificate: /C&lt;span class=&#34;o&#34;&gt;=&lt;/span&gt;US/ST&lt;span class=&#34;o&#34;&gt;=&lt;/span&gt;California/L&lt;span class=&#34;o&#34;&gt;=&lt;/span&gt;Mountain View/O&lt;span class=&#34;o&#34;&gt;=&lt;/span&gt;Google Inc/CN&lt;span class=&#34;o&#34;&gt;=&lt;/span&gt;imap.gmail.com - Connection failed.&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Simply searching this line:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-php&#34; data-lang=&#34;php&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;nv&#34;&gt;$open&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;imap_open&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s2&#34;&gt;&amp;#34;{imap.gmail.com:993/imap/ssl/}&lt;/span&gt;&lt;span class=&#34;si&#34;&gt;$path&lt;/span&gt;&lt;span class=&#34;s2&#34;&gt;&amp;#34;&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;And editing it to:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-php&#34; data-lang=&#34;php&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;nv&#34;&gt;$open&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;imap_open&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s2&#34;&gt;&amp;#34;{imap.gmail.com:993/imap/ssl/novalidate-cert}&lt;/span&gt;&lt;span class=&#34;si&#34;&gt;$path&lt;/span&gt;&lt;span class=&#34;s2&#34;&gt;&amp;#34;&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Solves the problem.&lt;/p&gt;&#xA;&lt;p&gt;This will ignore the Google certificate. Please do double check that imap.google.com really points to Google, and it&amp;rsquo;s not some kind of DNS issue.&lt;/p&gt;</description>
      <content:encoded><![CDATA[<p>I&rsquo;ve &ldquo;updated&rdquo; my <a href="https://yeri.be/gmail-automatic-mark-spam-as-read/" target="_blank" rel="noopener">previous php</a>-app.</p>
<p>Since today I ended up getting this error:</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">Warning: imap_open<span class="o">()</span>: Couldn<span class="err">&#39;</span>t open stream <span class="o">{</span>imap.gmail.com:993/imap/ssl<span class="o">}[</span>Google Mail<span class="o">]</span>/Spam in /home/yeri/.gmail.php on line <span class="m">30</span>
</span></span><span class="line"><span class="cl">Certificate failure <span class="k">for</span> imap.gmail.com: unable to get <span class="nb">local</span> issuer certificate: /C<span class="o">=</span>US/ST<span class="o">=</span>California/L<span class="o">=</span>Mountain View/O<span class="o">=</span>Google Inc/CN<span class="o">=</span>imap.gmail.com - Connection failed.
</span></span></code></pre></div><p>Simply searching this line:</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-php" data-lang="php"><span class="line"><span class="cl"><span class="nv">$open</span> <span class="o">=</span> <span class="nx">imap_open</span> <span class="p">(</span><span class="s2">&#34;{imap.gmail.com:993/imap/ssl/}</span><span class="si">$path</span><span class="s2">&#34;</span>
</span></span></code></pre></div><p>And editing it to:</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-php" data-lang="php"><span class="line"><span class="cl"><span class="nv">$open</span> <span class="o">=</span> <span class="nx">imap_open</span> <span class="p">(</span><span class="s2">&#34;{imap.gmail.com:993/imap/ssl/novalidate-cert}</span><span class="si">$path</span><span class="s2">&#34;</span>
</span></span></code></pre></div><p>Solves the problem.</p>
<p>This will ignore the Google certificate. Please do double check that imap.google.com really points to Google, and it&rsquo;s not some kind of DNS issue.</p>
<p>I&rsquo;ve <a href="https://static.yeri.be/2008/10/gmail_spamreader_v002.phps" target="_blank" rel="noopener">updated</a> the 1st version, that ignores the certificate.</p>
]]></content:encoded>
      <category>errors</category><category>linux</category><category>misc</category><category>networking</category><category>software</category>
      <category>gmail</category><category>imap</category><category>spam</category>
    </item>
    
    <item>
      <title>Gmail automatic &#34;mark (spam) as read&#34;</title>
      <link>https://yeri.be/gmail-automatic-mark-spam-as-read/</link>
      <pubDate>Wed, 27 Aug 2008 01:07:28 +0200</pubDate>
      <author>Yeri Tiete</author>
      <guid isPermaLink="true">https://yeri.be/gmail-automatic-mark-spam-as-read/</guid>
      <description>&lt;p&gt;I hate having unread mail. I hate having spam. And most of all, I hate spam that asks for attention.&lt;/p&gt;&#xA;&lt;p&gt;When receiving spam in Gmail, you get the annoying bold &lt;strong&gt;&lt;a href=&#34;https://static.yeri.be/2008/08/spam.png&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;Spam (12353434)&lt;/a&gt; &lt;/strong&gt;with &amp;lsquo;12353434&amp;rsquo; being the number of unread spam messages.&lt;/p&gt;&#xA;&lt;p&gt;With the introduction of Gmail Labs I&amp;rsquo;d hope to see an &amp;ldquo;automaticly mark spam message as seen&amp;rdquo; feature, which, well, I haven&amp;rsquo;t found yet.&lt;/p&gt;&#xA;&lt;p&gt;Being tired of all these increasing spam numbers, and my daily efforts to &amp;ldquo;select all unread + mark as read&amp;rdquo;, I ended up writing a small PHP file which connects to the Gmail (using IMAP, so I asume you&amp;rsquo;ll need IMAP enabled in your settings..) and marks all spam messages as read. Running this script locally with a curl or cron every X time will solve most of your problems, I hope.&lt;/p&gt;</description>
      <content:encoded><![CDATA[<p>I hate having unread mail. I hate having spam. And most of all, I hate spam that asks for attention.</p>
<p>When receiving spam in Gmail, you get the annoying bold <strong><a href="https://static.yeri.be/2008/08/spam.png" target="_blank" rel="noopener">Spam (12353434)</a> </strong>with &lsquo;12353434&rsquo; being the number of unread spam messages.</p>
<p>With the introduction of Gmail Labs I&rsquo;d hope to see an &ldquo;automaticly mark spam message as seen&rdquo; feature, which, well, I haven&rsquo;t found yet.</p>
<p>Being tired of all these increasing spam numbers, and my daily efforts to &ldquo;select all unread + mark as read&rdquo;, I ended up writing a small PHP file which connects to the Gmail (using IMAP, so I asume you&rsquo;ll need IMAP enabled in your settings..) and marks all spam messages as read. Running this script locally with a curl or cron every X time will solve most of your problems, I hope.</p>
<p>Download the file <a href="https://static.yeri.be/2008/08/gmail_spamreader.phps" target="_blank" rel="noopener">here</a> (phps) or <a href="https://static.yeri.be/2008/08/gmail_spamreader.txt" target="_blank" rel="noopener">here</a> (txt).</p>
<p>Or just copy paste it!</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-PHP" data-lang="PHP"><span class="line"><span class="cl"><span class="o">&lt;</span> <span class="o">?</span><span class="nx">php</span>
</span></span><span class="line"><span class="cl"><span class="cm">/*
</span></span></span><span class="line"><span class="cl"><span class="cm">Gmail &#34;spam mark-as-read&#34;
</span></span></span><span class="line"><span class="cl"><span class="cm">
</span></span></span><span class="line"><span class="cl"><span class="cm">by Tuinslak
</span></span></span><span class="line"><span class="cl"><span class="cm">www.tuinslak.be
</span></span></span><span class="line"><span class="cl"><span class="cm">
</span></span></span><span class="line"><span class="cl"><span class="cm">v0.01 :: 26/08/2008 . init php codez
</span></span></span><span class="line"><span class="cl"><span class="cm">*/</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="c1">// Config starts here
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl"><span class="c1">// Gmail user &amp; pass
</span></span></span><span class="line"><span class="cl"><span class="c1"></span><span class="nv">$user</span> <span class="o">=</span> <span class="s2">&#34;YOU&#34;</span><span class="p">;</span>
</span></span><span class="line"><span class="cl"><span class="nv">$pass</span> <span class="o">=</span> <span class="s2">&#34;hiddensecretz&#34;</span><span class="p">;</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="c1">// Debugging - Outputs a list of mailboxes and status on the imap server (1/0)
</span></span></span><span class="line"><span class="cl"><span class="c1"></span><span class="nv">$listmailbox</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="c1">// Advanced config :o
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl"><span class="c1">// &#34;Path&#34; of the (spam) mailbox and/or its name.
</span></span></span><span class="line"><span class="cl"><span class="c1">// default should be ok with Gmail.
</span></span></span><span class="line"><span class="cl"><span class="c1"></span><span class="nv">$path</span> <span class="o">=</span> <span class="s2">&#34;[Google Mail]/Spam&#34;</span><span class="p">;</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="c1">// End of config
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl"><span class="nv">$open</span> <span class="o">=</span> <span class="nx">imap_open</span> <span class="p">(</span><span class="s2">&#34;{imap.gmail.com:993/imap/ssl}</span><span class="si">$path</span><span class="s2">&#34;</span><span class="p">,</span> <span class="nv">$user</span><span class="p">,</span> <span class="nv">$pass</span><span class="p">,</span> <span class="s2">&#34;&#34;</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span> <span class="k">or</span> <span class="k">die</span><span class="p">(</span><span class="nx">imap_last_error</span><span class="p">()</span> <span class="o">.</span> <span class="s2">&#34;
</span></span></span><span class="line"><span class="cl"><span class="s2">
</span></span></span><span class="line"><span class="cl"><span class="s2">Connection failed.&#34;</span><span class="p">);</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="c1">// debug
</span></span></span><span class="line"><span class="cl"><span class="c1"></span><span class="k">if</span><span class="p">(</span><span class="nv">$listmailbox</span><span class="p">)</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl">        <span class="k">echo</span> <span class="s2">&#34;&lt;strong&gt;Mailboxes:&#34;</span><span class="p">;</span>
</span></span><span class="line"><span class="cl">        <span class="nv">$folders</span> <span class="o">=</span> <span class="nx">imap_listmailbox</span><span class="p">(</span><span class="nv">$open</span><span class="p">,</span>  <span class="s2">&#34;{  Gmail  }&#34;</span><span class="p">,</span> <span class="s2">&#34;*&#34;</span><span class="p">);</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">        <span class="k">if</span> <span class="p">(</span><span class="nv">$folders</span> <span class="o">==</span> <span class="k">false</span><span class="p">)</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl">                <span class="k">echo</span> <span class="s2">&#34;Call failed</span><span class="se">\n</span><span class="s2">&#34;</span><span class="p">;</span>
</span></span><span class="line"><span class="cl">        <span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl">                <span class="k">foreach</span> <span class="p">(</span><span class="nv">$folders</span> <span class="k">as</span> <span class="nv">$val</span><span class="p">)</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl">                        <span class="k">echo</span> <span class="nv">$val</span> <span class="o">.</span> <span class="s2">&#34;</span><span class="se">\n</span><span class="s2">&#34;</span><span class="p">;</span>
</span></span><span class="line"><span class="cl">                <span class="p">}</span>
</span></span><span class="line"><span class="cl">        <span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">        <span class="k">echo</span> <span class="s2">&#34;&lt;/strong&gt;&lt;strong&gt;Status&lt;/strong&gt;:&#34;</span><span class="p">;</span>
</span></span><span class="line"><span class="cl">        <span class="nv">$status</span> <span class="o">=</span> <span class="nx">imap_status</span><span class="p">(</span><span class="nv">$open</span><span class="p">,</span> <span class="s2">&#34;{imap.gmail.com}</span><span class="si">$path</span><span class="s2">&#34;</span><span class="p">,</span> <span class="nx">SA_ALL</span><span class="p">);</span>
</span></span><span class="line"><span class="cl">        <span class="k">if</span> <span class="p">(</span><span class="nv">$status</span><span class="p">)</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl">                <span class="k">echo</span> <span class="s2">&#34;Messages:   &#34;</span> <span class="o">.</span> <span class="nv">$status</span><span class="o">-&gt;</span><span class="na">messages</span>    <span class="o">.</span> <span class="s2">&#34;</span><span class="se">\n</span><span class="s2">&#34;</span><span class="p">;</span>
</span></span><span class="line"><span class="cl">                <span class="k">echo</span> <span class="s2">&#34;Recent:     &#34;</span> <span class="o">.</span> <span class="nv">$status</span><span class="o">-&gt;</span><span class="na">recent</span>      <span class="o">.</span> <span class="s2">&#34;</span><span class="se">\n</span><span class="s2">&#34;</span><span class="p">;</span>
</span></span><span class="line"><span class="cl">                <span class="k">echo</span> <span class="s2">&#34;Unseen:     &#34;</span> <span class="o">.</span> <span class="nv">$status</span><span class="o">-&gt;</span><span class="na">unseen</span>      <span class="o">.</span> <span class="s2">&#34;</span><span class="se">\n</span><span class="s2">&#34;</span><span class="p">;</span>
</span></span><span class="line"><span class="cl">                <span class="k">echo</span> <span class="s2">&#34;UIDnext:    &#34;</span> <span class="o">.</span> <span class="nv">$status</span><span class="o">-&gt;</span><span class="na">uidnext</span>     <span class="o">.</span> <span class="s2">&#34;</span><span class="se">\n</span><span class="s2">&#34;</span><span class="p">;</span>
</span></span><span class="line"><span class="cl">                <span class="k">echo</span> <span class="s2">&#34;UIDvalidity:&#34;</span> <span class="o">.</span> <span class="nv">$status</span><span class="o">-&gt;</span><span class="na">uidvalidity</span> <span class="o">.</span> <span class="s2">&#34;</span><span class="se">\n</span><span class="s2">&#34;</span><span class="p">;</span>
</span></span><span class="line"><span class="cl">        <span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl">                <span class="k">echo</span> <span class="s2">&#34;imap_status failed: &#34;</span> <span class="o">.</span> <span class="nx">imap_last_error</span><span class="p">()</span> <span class="o">.</span> <span class="s2">&#34;</span><span class="se">\n</span><span class="s2">&#34;</span><span class="p">;</span>
</span></span><span class="line"><span class="cl">        <span class="p">}</span>
</span></span><span class="line"><span class="cl"><span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="c1">// Mark as read
</span></span></span><span class="line"><span class="cl"><span class="c1"></span><span class="nv">$search</span> <span class="o">=</span> <span class="nx">imap_search</span><span class="p">(</span><span class="nv">$open</span><span class="p">,</span> <span class="s1">&#39;UNSEEN&#39;</span><span class="p">);</span>
</span></span><span class="line"><span class="cl"><span class="c1">// print out the array containing $search info
</span></span></span><span class="line"><span class="cl"><span class="c1">//print_r($search);
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl"><span class="k">for</span> <span class="p">(</span><span class="nv">$i</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span> <span class="nv">$i</span> <span class="o">&lt;</span> <span class="nx">sizeof</span><span class="p">(</span><span class="nv">$search</span><span class="p">);</span> <span class="nv">$i</span><span class="o">++</span><span class="p">)</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl">        <span class="nv">$read</span> <span class="o">=</span> <span class="nx">imap_setflag_full</span><span class="p">(</span><span class="nv">$open</span><span class="p">,</span> <span class="nv">$search</span><span class="p">[</span><span class="nv">$i</span><span class="p">],</span> <span class="s1">&#39;\\Seen&#39;</span><span class="p">);</span>
</span></span><span class="line"><span class="cl"><span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="c1">// and close it down !
</span></span></span><span class="line"><span class="cl"><span class="c1"></span><span class="nx">imap_close</span><span class="p">(</span><span class="nv">$open</span><span class="p">);</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="c1">// EOF
</span></span></span><span class="line"><span class="cl"><span class="c1"></span><span class="cp">?&gt;</span><span class="err">
</span></span></span></code></pre></div><p>If you plan to execute it from shell, don&rsquo;t forget to add a <a href="http://en.wikipedia.org/wiki/Shebang_(Unix)" target="_blank" rel="noopener">shebang</a> &ldquo;#!/usr/bin/php&rdquo; on line 1 and chmod +x gmail_spamreader.php.</p>
<p><span style="color: #888888;"><em>Edit:</em> Please add a comment if you&rsquo;re using it, just for statistics. :)</span></p>
]]></content:encoded>
      <category>errors</category><category>linux</category><category>misc</category><category>networking</category><category>software</category>
      <category>gmail</category><category>imap</category><category>spam</category>
    </item>
    
  </channel>
</rss>
