Categories
Errors Linux Misc Networking Software

Gmail automatic “mark (spam) as read”

I hate having unread mail. I hate having spam. And most of all, I hate spam that asks for attention.

When receiving spam in Gmail, you get the annoying bold Spam (12353434) with ‘12353434’ being the number of unread spam messages.

With the introduction of Gmail Labs I’d hope to see an “automaticly mark spam message as seen” feature, which, well, I haven’t found yet.

Being tired of all these increasing spam numbers, and my daily efforts to “select all unread + mark as read”, I ended up writing a small PHP file which connects to the Gmail (using IMAP, so I asume you’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.

Download the file here (phps) or here (txt).

Or just copy paste it!

< ?php
/*
Gmail "spam mark-as-read"
 
by Tuinslak
www.tuinslak.be
 
v0.01 :: 26/08/2008 . init php codez
*/
 
// Config starts here
 
// Gmail user &amp; pass
$user = "YOU";
$pass = "hiddensecretz";
 
// Debugging - Outputs a list of mailboxes and status on the imap server (1/0)
$listmailbox = 0;
 
// Advanced config :o
 
// "Path" of the (spam) mailbox and/or its name.
// default should be ok with Gmail.
$path = "[Google Mail]/Spam";
 
// End of config
 
$open = imap_open ("{imap.gmail.com:993/imap/ssl}$path", $user, $pass, "", 1) or die(imap_last_error() . "
 
Connection failed.");
 
// debug
if($listmailbox) {
        echo "<strong>Mailboxes:";
        $folders = imap_listmailbox($open,  "{  Gmail  }", "*");
 
        if ($folders == false) {
                echo "Call failed\n";
        } else {
                foreach ($folders as $val) {
                        echo $val . "\n";
                }
        }
 
        echo "</strong><strong>Status</strong>:";
        $status = imap_status($open, "{imap.gmail.com}$path", SA_ALL);
        if ($status) {
                echo "Messages:   " . $status-&gt;messages    . "\n";
                echo "Recent:     " . $status-&gt;recent      . "\n";
                echo "Unseen:     " . $status-&gt;unseen      . "\n";
                echo "UIDnext:    " . $status-&gt;uidnext     . "\n";
                echo "UIDvalidity:" . $status-&gt;uidvalidity . "\n";
        } else {
                echo "imap_status failed: " . imap_last_error() . "\n";
        }
}
 
// Mark as read
$search = imap_search($open, 'UNSEEN');
// print out the array containing $search info
//print_r($search);
 
for ($i = 0; $i &lt; sizeof($search); $i++) {
        $read = imap_setflag_full($open, $search[$i], '\\Seen');
}
 
// and close it down !
imap_close($open);
 
// EOF
?>

If you plan to execute it from shell, don’t forget to add a shebang “#!/usr/bin/php” on line 1 and chmod +x gmail_spamreader.php.

Edit: Please add a comment if you’re using it, just for statistics. 🙂

Categories
Misc

Pingback tests

You’ll have to excuse me for this pointless post, I’m testing my Pingback options.

And yes, @sphere, even this summer was pretty poor…

Categories
Misc

Heh

Might be old, but still made me laugh. 😉

Categories
Misc

iPhone

Is mine & is working. Happy again.

Mobistar also said the warranty is two years. No matter what Apple says.

Categories
Misc

Mobistar “lulling” around

I just can’t stand the fact when people start lying or talk bullshit.

On the phone, the Mobistar employee guaranteed me the repair will take no longer than 5 work days.

In the Mobistar shop: “This is wrong, it will take <at least> 10 work days”.

In the meanwhile, I’ll just bang my head against the wall some more.

As I still have not received the receipt, and no one is able to tell me where it is, or when it arrives (“you’ll have it by next week”, “max 3 days”, “it takes at least 2 to 3 weeks before you’ll have it”), and they told me I could get my iPhone repaired with my MasterCard payment proof (uhhhh…).

Anyway, now that I’ve recieved that payment proof (mailed once per month) I went to the Mobistar shop, saying “Repair nowz plx!” & they already backed off, saying “Well, if for Dynafix this is not enough proof, it’s possible you’ll have to pay for the repair… And once the iPhone is sent, and they think it’s not enough proof, this cannot be stopped”.

I mean… What the fuck.

1) In what country, do they repair stuff for you, before you even agree to the repair cost?!

2) WTF is Mobistar doing in all this. They told me it’s proof, so what on earth has Dynafix have to say.

3) Sheesh, check the freaking serial/imei number, yes, check my address & name, yes, figure out… THINK FOR JUST ONCE. I. have. bought. it. legally. online. on. the. fucking. mobistar.be. site.

4) AAAARGH no one, but really NO ONE has any clue about this whole iPhone. It’s an unorganised last minute “hey pick me, pick me Apple, yes, we r so pr0, we have 40% 3G coverage, pewpew & are customer mindeth”. Not a single person knows, for 100% sure, what to do. “You might try X… But…” or “You have to wait for the receipts, that will arrive in less than a month”. YES!! I’ve got time, with one freaking year of warranty, when it should be two.