phpMailer – Could not instantiate mail function

Had a client getting this error when trying to send emails last week and have now spent several hours on Google trying to find a solution.

Biggest catch is that other scripts were able to send mail, so it seemed unlikely that it was the host. So I took the phpMailer class and uploaded it to a test folder and wrote a script that did pretty much exactly what ProofBuddy does and it worked just like it should.

After much confusion on my part, I discovered a typo in the email address that was used for sending. A character was left out – exampl.com instead of example.com. Guess 1&1 had something in place that checked if it was a valid domain before sending out.

I’m sure there’s a lesson in there somewhere. Either way, I’m glad it wound up being something relatively simple even if it did take me way too long to get there.

Bookmark and Share

bit.ly and PHP

Needed a quick and easy way to create a bit.ly URL for another site of mine. Google came through for me.

David Walsh posted a short PHP function on his site that takes your bit.ly login, API key, and the URL to shorten and returns a nice, short bit.ly link.

Link: http://davidwalsh.name/bitly-php

Just put the function into your file and...

PHP:
  1. $shortURL = make_bitly_url($longURL, $bitlyLogin, $bitlyAPIKey);

And that's it. A new bit.ly URL is created and stored in $shortURL for you.

I started using this on my @DailyFont Twitter feed today to post fonts as they're added to the site and after a couple of test Tweets it seems to be working without a hitch.

Bookmark and Share

Missing httpd.conf in WHM / cPanel

Came across an error after mistakenly clicking a link in my hosting control panel.

CODE:
  1. Unable to locate httpd.conf at /usr/local/cpanel/Cpanel/ConfigFiles.pm line 27.
  2. Cpanel::ConfigFiles::find_httpconf(undef) called at /usr/local/cpanel/Cpanel/ApacheConf.pm line 206
  3. Cpanel::ApacheConf::loadhttpdconf() called at whostmgr/bin/whostmgr4 line 197
  4. main::listaccts() called at whostmgr/bin/whostmgr4 line 157

At the time, WHM was working but none of the sites on the server would load. Trying to restart httpd manually from PuTTY resulted in an error that httpd.conf couldn't be found.

Fortunately, there was an easy fix.

CODE:
  1. /scripts/rebuildhttpdconf

It's a script included with WHM that rebuilds the httpd.conf file. Ran it, waited a couple of minutes while the server churned, started Apache, and everything was back to normal.

Bookmark and Share

Quick PHP wrapper for print_r

Working on web apps I find myself using the print_r command a lot, and I mean a lot. It helps trace out what data is going where, and more often what's not going where it's supposed to.

A few months ago I realized that I type this same bit of code way too often.

PHP:
  1. echo '<pre>';
  2. print_r($variable);
  3. echo '</pre>';
  4. die();

Does a nice job of wrapping the output in<pre> tags making it easier to trace through.  But too much typing for as many times as I use it.  So I spent 2 minutes kicking out a function named pre_r that does it for me.

PHP:
  1. /**
  2. * Wrapper for print_r with pre tags
  3. * @param mixed $data   What to display
  4. * @param boolean $die  Whether the function should die() at the end
  5. */
  6. function pre_r($data, $die=false) {
  7.      echo '<pre>';
  8.      print_r($data);
  9.      echo '</pre>';
  10.      if ($die) {
  11.          die();
  12.      }
  13. }

Bookmark and Share

Mario on a sidewalk curb

Definitely cool for those of y'all that grew up playing Mario.

Bookmark and Share

Netbeans with multiple monitors

How did I not try this before today?

My normal method of needing two files open was to have the one I'm working on in Netbeans and the other in Notepad++ on separate monitors.  Turns out you can drag the tab of an open file outside of Netbeans and it becomes its own window.

We're going to have to file that one under the wish I had thought of that a long time ago category.

Bookmark and Share

Java vs. .Net – Movie Trailer

Bookmark and Share

Alka-Seltzer in space

What happens when you put an Alka-Seltzer in water with no gravity?

Bookmark and Share

Safari, scriptaculous, and non-clickable links

For the better part of the last couple of days I've been trying to figure out why Safari was not allowing me to click on links. Aside from an annoyance, it's not good to have clients complaining... Read the rest of this entry »

Bookmark and Share

Get an image of iPhone without iTunes

Found myself needing to get an image off of my iPhone without using iTunes. On my Vista machine it's easy enough. The iPhone shows up as a device and it's browsable just like any camera.

Turns out it's just about that easy on my MacBook.  Fired up Image Capture, selected the phone, and they were there.  Just a matter of dragging and dropping the image I wanted and it was done.

Bookmark and Share