Wednesday, April 29, 2009

Invalid Arguments 501 5.5.4 Error when sending SMTP email through exchange

OK, I recently needed to do a quick and dirty mail send from java using an exchange server. I kept getting a 501 5.5.4 error back, which is Invalid Arguments to the RSET method. It turns out, when looking at the example:

I had neglected to set the submitter properly. When googling, all of the discussions were around trailing dots or spaces. After wiresharking it, I finally saw the problem.

Word to the wise, make sure when you are using AUTH with SMTP to set the submitter properly.

Tuesday, April 21, 2009

Vanilla Discussion Forum : Initial Login Problems

In the past I've been a big phpBB fan, but recently I've wanted a leaner meaner discussion forum for integration into an existing site/application. I stumbled upon Vanilla.

So far, I'm a big fan. I did have some trouble getting setup though. When installing, you set the COOKIE_DOMAIN, which php then uses to store your cookie. This needs to match the url through which you are accessing the site. If it does not, the authentication will work but you will not be signed in. In other words, if you type in the wrong password you will be rejected. If you type in the correct password you will be forwarded to the main page, but you will still see the option to sign in up in the top right hand corner.

Specifically this will happen if you have it deployed locally and access it using "localhost". In this case, simply map your deployment domain to your local IP address in your /etc/hosts file.

Also make sure your conf/settings.php contains the correct domain. I searched for localhost in that file and made sure all were changed to be the deployment domain.

I hope this helps anyone trying to get started with Vanilla.

Wednesday, April 15, 2009

Building a REST Service in PHP

OK, I'm a big fan of using the right tool for the job. Daily I switch between Rails, Java and PHP. Rails is probably the easiest to use for developing a REST Service, but sometimes you don't want the overhead of a rails server and you want that feel good all over sense of stability that LAMP gives you.

First, I created an alias to send all requests to a single php file (service.php).

AliasMatch /Beers/.* /var/www/

This sends all* requests to service.php. Then, I created a generic service class. This grabs the method, id and the target object from the url, and uses reflection to invoke the appropriate method on a service class. The code for the service.php class is below.

include 'beer.php';
header('Content-Type: text/xml');
$method = strtolower($_SERVER["REQUEST_METHOD"]);
$object = $_SERVER["REQUEST_URI"];
$object = substr($object, 1, strlen($object)-1);
$vars = explode("/", $object);
$object = $vars[0];
$id = $vars[1];
// echo "method ==> (".$method.")
// echo "object ==> (".$object.")
// echo "id ==> (".$id.")";
$method = new ReflectionMethod($object, $method);
echo $method->invoke(NULL, $id);

In the above code, the request is received, the Beer object is created and the get() method is invoked on that object with the id supplied as a parameter. So, when is requested. Beer->get(1234) is invoked.

Its that simple.

Wednesday, April 8, 2009

Fixing Sendmail (dead.letter issue)

OK, we have lots of machines that we host out on slicehost. We want them to be part of our domain ( So, we configure their hostname to be that. Unfortunately, we want them to be able to send mail to people in our domain ( Since the machine thinks it is part of the domain, it looks for that user, can't find them and consequently fails to send the mail out.

Testing sendmail, it always drops the mail into dead.letter immediately.

To fix this, I simply edited /etc/mail/ and uncommented the domain, setting it to some fictitious name (since the machine won't be the destination for any mail.

I uncommented this line: