Throttling outgoing emails to certain domains with Postfix

March 29th, 2009 Mohammad Al-Shami No comments

I’ve been busy setting up a PHPlist server for my employer. All tests went ok, but as soon as we sent our first newsletter Yahoo! blocked the server. After looking around for a solution people suggested we sign all outgoing emails with DomainKeys and not hammer Yahoo’s servers with consecutive connection.

Using DomainKeys was a simple setup with DKIMproxy, as for throttling, you all know Postfix is one high performance MTA, so that would be hard to do. PHPlist has a throttling feature but I didn’t want to use that because it would slow emails going to all domains and it took about half a day to send messages to about 6,000 users. That is unacceptable.

After some more digging around I found that Postfix 2.5 introduced the perfect solution, here you go:

First, add the following lines to your master.cf


domain1      unix  -       -       n       -       -       smtp
        -o smtp_fallback_relay=
domain2      unix  -       -       n       -       -       smtp
        -o smtp_fallback_relay=
domain3      unix  -       -       n       -       -       smtp
        -o smtp_fallback_relay=

Now, to use those transports add these lines to your transport_maps file


domain1.tld    domain1:
domain2.tld    domain2:
domain3.tld    domain3:

Finally, set the destination_rate_delay for those transports in main.cf


domain1_destination_rate_delay = 10s
domain2_destination_rate_delay = 20s
domain3_destination_rate_delay = 30s

This will effectively send all outgoing messages at full speed, except for messages going to domain1.tld, domain2.tld, and domain3.tld; Postfix will wait 10/20/30 seconds after sending each message to domain1.tld/domain2.tld/domain3.tld.

Categories: Mail Tags:

Fixing MySQL Error 1064 with PHPList when selecting new criteria

March 14th, 2009 Mohammad Al-Shami 10 comments

I’m currently experimenting with PHPlist to use for our corporate newsletters. During the tests I got the following error

Database error 1064 while doing query You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘1)’ at line 3

Tracking this problem down I found the following code segment in “admin/send_core.php”


if (is_array($_POST["criteria_values"])) {
$values = join(", ",$_POST["criteria_values"]);
} else {
$values = $_POST["criteria_values"];
}

$values in this segment will always start with a comma. We just need to add a substr statement to fix that. Just change it to


if (is_array($_POST["criteria_values"])) {
$values = join(", ",$_POST["criteria_values"]);
} else {
$values = $_POST["criteria_values"];
}
if (substr($values, 0, 1) == ",") {
$values = substr($values, 1);
}

That’s it. This will remove the starting comma (If it exists)

Categories: Mail, Technical Tags:

Solving the frowning issue

February 28th, 2009 Mohammad Al-Shami No comments

Jordanians are known for frowning. I hereby propose a cheap, yet efficient solution:

First, get a couple of paper clips and a couple of rubber bands


Attach as follows
Now install

Just make sure the rubber bands are stronger than your frown :)

Categories: Funny Tags:

Happy Valentine’s Day

February 14th, 2009 Mohammad Al-Shami No comments

For all of you out there, happy Valentine’s Day. Yeah right! I don’t celebrate it, there are more important things in this world, just look at the comic below, inspired by real Jordanian lives.

Translation: Abu-Mahjoob celebrating Valentine’s Day.

Categories: Funny Tags:

Empathy, the new kid on the block

February 5th, 2009 Mohammad Al-Shami No comments

If you’ve used Linux as a desktop, you’ll know it’s only playing catch-up when it comes to instant messaging. I’ve been using Pidgin since was called Gaim, I think I started using it back in 2003. I love how minimalistic it is. Sadly the developers are going nowhere with it, at least that’s my (as well as a few others) humble opinion.

I stumbled upon this post which mentions a new (or maybe just new to me) client called Empathy. After playing with it for a few days now I think it has great potential. It’s still pretty basic but also under heavy development. It’s very minimalistic and uses the Telepathy library, which IMHO is a better approach than Pidgin’s libpurple.

It still doesn’t have proxy support, but you can work around that, at least for MSN and Gtalk, the protocols that I use. Here is how I did it it:

Gtalk: Just create a tunnel with SSH


ssh -C -q -f -M 0 -N -L 5223:209.85.137.125:5223

Where 209.85.137.125 is the IP address of talk.google.com, then set the account to use localhost as a server

MSN is a little different, this trick didn’t work because the client connects to a login server, which redirects the client to a different server. MSN is implemented using the telepathy-butterfly executable. Just use a socks server like this:


mv /usr/lib/telepathy/telepathy-butterfly /usr/lib/telepathy/telepathy-butterfly-old
vi /usr/lib/telepathy/telepathy-butterfly

#!/bin/bash
exec /usr/bin/tsocks /usr/lib/telepathy/telepathy-butterfly-old

chmod +x /usr/lib/telepathy/telepathy-butterfly

Enjoy :)

Categories: Linux Tags:

Alf mabrook Tamer

February 5th, 2009 Mohammad Al-Shami No comments

This is a shout out to my old friend Tamer, yet another fallen soldier from the ranks of bachelorism. We attended his wedding last night it was awesome!

Congrats man and good luck on your new life

Categories: Misc Tags:

Xbox 360

February 2nd, 2009 Mohammad Al-Shami 4 comments

So I finally coughed up the money to get an Xbox 360, the thing is, every store that sells the Xbox in Jordan is highly overpriced (423$ as opposed to 199$ for the Arcade version) and the consoles are VERY old, dating back to 2007. This means they are using the old chips which are highly not recommended. A friend of mine, Tamer, came from Bahrain Friday and was kind enough to pick up the console for me. Thanks man ^_^.

I just had to take some pictures of the event. Enjoy :)


Categories: Misc Tags:

Bulls**t

February 2nd, 2009 Mohammad Al-Shami No comments

Weird title, I know. It’s the title of a ShowTime series hosted by Penn & Teller, which I thought was appropriate for this rant. The thing is, I hate it when people act like jerks.

I work in Shmeasani, one of the busiest neighborhoods in Amman. It’s so jammed you can barely find free parking, and if you go with paid parking, you can pay up to 3 times the normal fees. As always, some people think they are better than everybody else, they erect poles and chain them together in front of their houses so people can’t park there. What kind of attitude is that?

I have seen this with my own eyes, when someone wants to visit this guy, they park in front of one of the neighbors’ houses. Quoting Penn. “And then there’s THIS a**hole” who actually has blocked parking in front of his house, where does he park? You guessed it, in front of his neighbor’s.

Does it annoy me when lots of people park in front of my house, yes, because I can’t park, but it’s no big deal. Does it happen? Sometimes. What do I do about it? Nothing, people need some place to park.

Word of advice, don’t do to others what you don’t like happening to you, A**hole!

Categories: Rants Tags:

Google Chrome on Ubuntu

September 5th, 2008 Mohammad Al-Shami 2 comments

I came across this guide about installing Google Chrome under Ubuntu. It is somewhat slow, slower than Windows and much slower than Firefox but it still works, well, kinda. You have a few problems with fonts, as well as sites that don’t work properly with Chrome yet. I’m sticking with Firefox for the time being, but at least I have an option for those sites that aren’t compatible with it.

I wrote this post from Chrome, so yeah, it does work :)

Categories: Linux, Technical Tags:

Slow Browsing Under Ubuntu

August 23rd, 2008 Mohammad Al-Shami 2 comments

EDIT: This post only covers IPv6, please check the update post which covers IPv6 and Firefox

Today when I rebooted to my Windows installation which I very rarely do, I noticed that browsing under Windows feels much faster than under Ubuntu. After booting back to Ubuntu I noticed the “looking up domain.tld” part was taking a lot of time, which seemed a little odd.

Anyways, after some googling I found out that Debian enables IPv6 by default and uses that before and uses it before IPv4. A quick remedy was:

sudo vi /etc/modprobe.d/bad_list

#Add this line
alias net-pf-10 off

After which you should reboot your system. Now browsing feels much faster. To speed it up a little I installed a local caching DNS server which works like a charm. A quick HOWTO can be found here

Hope this helps.

Categories: Linux, Technical Tags: , , , ,