Pear not working for PHP 5.3


#1

After naively updating to PHP 5.3 via the dreamhost webpanel, it has broken my website and I can no longer send out email via Pear. I now get the following error:

Deprecated: Assigning the return value of new by reference is deprecated in /usr/local/lib/php/Mail.php on line 134

which is caused by this line in my php file:
require_once( ‘Mail.php’ );

I have yet to find a solution to this issue in regards to dreamhost. I am desperate to get email working again for my users. Hopefully someone has a solution. Even if you know how I can go back to a previous version that works with Pear.

(Editorial - It chaps my hide that dreamhost gave no warning of this issue when providing the update link on the control panel. It should have had a warning stating “if you choose to update, PEAR will no longer work”.)


#2

Day 2…grrr…more frustration ensues…

So, I’m guessing I need to upgrade my version of Pear. To that end I have tried the following:

$ pear upgrade Mail
WARNING: channel “pear.php.net” has updated its protocols, use “pear channel-update pear.php.net” to update
Cannot install, php_dir for channel “pear.php.net” is not writeable by the current user

$ pear channel-update pear.php.net
Updating channel "pear.php.net"
Registry directory is not writeable by the current user

So from these messages, I’m concluding that dreamhost will not allow me to upgrade my version of Pear (insufficient rights). I have also tried ‘install’ as opposed to ‘upgrade’ - same results.

I really hate to just edit my usr/local/lib/php/Mail.php file (I wonder if it will even let me?), but these are desperate times.

Anyone…anyone…Bueller?


#3

So I finally got rid of the deprecation error (although I’m not yet convinced that my email is working but that’ll be a different thread. Also, I’m wondering if there is an easier solution).

The solution:

It turns out that my site was using a ‘shared’ pear folder, which is located in /usr/local/lib/php/pear. The basic user cannot update this location. So if you want to use PHP 5.3, you’ll have to install your own version of the latest pear to your own home directory (/home/username/pear/php). To do this issue the following two commands:

pear config-create ${HOME} ${HOME}/.pearrc
pear install -o PEAR

You should now see the folder /home/username/pear/php

You now have some basic Pear files, but what I also needed was Mail and SMTP. So I issued the following commands:

pear install pear/Mail
pear install pean/Net_SMTP

In theory, I should now have all the packages I need for sending outgoing mail via pear and SMTP.

The last step is that now my php code needs to stop using pear from /usr/local and start using it from /home/username. To do this modify the include path by prepending the /home/username/pear/php folder. Add something like the following in your php file.

$sHomeRoot = $_SERVER[‘DOCUMENT_ROOT’];

set_include_path(
".".PATH_SEPARATOR.
$sHomeRoot.PATH_SEPARATOR.
$sHomeRoot."/pear/php".PATH_SEPARATOR.
get_include_path()
);

I am assuming the reader has reasonable knowledge of php.

One last pointer. I talk about issuing commands. This is being done thru a BASH shell. If you don’t have one, download Putty.exe (this is what I’m using on my Windows computer). And run it. Login and you’re set. Search google for docs, but ‘help’ will probably get most users what they need.

Also, this site proved useful: http://wiki.dreamhost.com/PEAR, although it misses a bit of the justifications, and gives details that were tangents to the problem I was trying to solve.

I found it disappointing that there doesn’t seem to be a way to simply modify the include path to point to a newer version of Pear, but instead it instructs me to install my own, and then point to it. This is really inefficient for everyone to go thru this exercise.

If I find an easier way (there has got to be!). I’ll post again.


#4

So as I feared, although I no longer get any error messages when I send my email, the email never actually gets delivered, and I’m getting no feedback as to what is the cause. Keep in mind this all worked before upgrading to Php 5.4.

I’m pretty sure there is nothing wrong with this code, but I provide it for your inspection:

require_once( ‘Mail.php’ );

define( MAIL_PORT_NO, “587” );
define( SMTP_HOST, “mail.example.net” );
define( SMTP_USET, "xxxxx@example.net" );
define( SMTP_PASS, “xxxxxx” );

$aSMTPLogin = array (
‘auth’ => true,
‘port’ => MAIL_PORT_NO,
‘host’ => SMTP_HOST,
‘username’ => SMTP_USER,
‘password’ => SMTP_PASS
);

$aHeaders = array (
‘From’ => $sFromEmail,
‘Return-Path’ => $sFromEmail,
‘To’ => $sSendTo,
‘Subject’ => $sSubject,
‘MIME-Version’ => “1.0”,
‘Content-Type’ => “text/html; charset=iso-8859-1”
);

$smtp = Mail::factory( ‘smtp’, $aSMTPLogin );
$mail = $smtp->send( $sSendTo, $aHeaders, $sMessage );

All variables are legally define (this use to work). So I suspect there is something wrong with my Pear installs??? If anyone has any suggestions I’m all ears. As it is right now, my sites no longer have email, and according to Dreamhost, they won’t support Pear (although they have it install). Exactly what are they trying to tell the customer??? Because I’m picking it up loud and clear.

Does anyone recommend another ISP beside Dreamhost. I’ve been having issue with their email system for about two years, and their support has been horrible. Took me about four months of back and forth emails, and jumping through hoops, just to get them to raise my quota, and even now they never could resolve my issue that bounced email doesn’t come back to my mailbox; instead it gets stuck in Maildir/new and it’s up to me to shell in and try to inspect them. And even then the folder gets so full of emails, I can’t view it or delete them via ftp. I’ve been a customer since forever (1998?), so it is going to be a major pain to move all my sites; but it has gotten that bad.