Archive for the ‘Web Development’ Category

PHP mail() And Gmail - A Warning on Headers

Posted on December 7th, 2005 in Web Development, Linux, Fixit, Code | 9 Comments »

Today, out of nowhere, we started receiving reports that HTML email the gdiapers.com site was sending were showing up as just that: HTML code and not much else. Running a few tests confirmed these reports… but only in my gmail account. We went back and checked the reports and sure enough - they were all coming from gmail users.

After some tinkering and futzing around we realized that the Windows line breaks that we had after the headers (\r\n) were the problem. Here’s an example:

This will show up as two line breaks in gmail and trash your HTML formatting:
$headers = "MIME-Version: 1.0\r\n";

This, however, will fix the problem and show up in gmail just fine:
$headers = "MIME-Version: 1.0\n";

I’m sure if you were sending mail from a Windows server this may not be the case, but for those on a Unix box, just stick with \n. Google will thank you by displaying your HTML email the way it was meant to be displayed - without raw code!

Enable mod_rewrite on OS X 10.4 (Tiger)

Posted on November 21st, 2005 in Web Development, Apache, Fixit, OS X | 29 Comments »

Tiger has introduced a new super-confusion level to the stock configuration of Apache. In addition to the httpd.conf file in the /etc/httpd directory, there’s now a new users directory as well. That directory holds unique config files for each user of the machine. So, if you were to enable mod_rewrite or AllowOverrides in httpd.conf, you may find that it doesn’t quite cut the mustard in your personal Sites directory. Let’s take a look:

To enable mod_rewrite:

  1. Open /etc/httpd/httpd.conf
    (I highly recommend TextMate - from the command line you can simply type this:
    $ mate /etc/httpd/httpd.conf
    or use the old standards: vi, vim, whathaveyou)
  2. Go to line 223 (if your config file just so happens to jive with mine) and uncomment the following line:
    LoadModule rewrite_module libexec/httpd/mod_rewrite.so
    (mind the wrap)
  3. Go to line 267 and uncomment the following line:
    AddModule mod_rewrite.c
  4. Scroll down to line 408 and change the line to read:
    AllowOverride All
    (Some server admins will tell you this may not be the best idea for hosting a live site, but I’m assuming you’re using this for local development only, right?)
  5. Uncomment line 454:
    AccessFileName .htaccess
  6. Restart Apache:
    $ sudo apachectl restart

At this point you should have mod_rewrite happily fixing your ugly URL’s in the /Library/WebServer/Documents directory, but it’s not working in your /Users/you/Sites directory. What gives? Here’s the trick:

  1. Open the yourname.conf file in the /etc/httpd/users folder.
  2. Change the first two lines to this:
    Options All
    AllowOverride All
  3. Give Apache another bounce:
    $ sudo apachectl restart

You should now be seeing friendly url’s in your very own Sites directory.

Close
E-mail It