anyone using php5 and the PEAR Mail to send smpt mail?

I have been using the php module that comes with OS X server, and the PEAR class for sending smtp mail. Everything has been working fine until recently. I upgraded to php5 because of its nice features like mcrypt. I dowloaded and installed php 5.1.2 from the Marc Liyanage website. Afterwards I noticed the php module and mcrypt are working fine, but no longer can I send mail now. I am able to use other PEAR classes like HTML/Table.php with no problems but am having difficulties with Mail, more specifically the send function. When the page loads all I get is a blank screen and the line that is causing the problem is the last one, the send funcion. Here is the code:

require_once ('PEAR.php');
require_once ('Mail.php');

$recipients = 'my email';

$headers['From'] = 'doesnt matter';
$headers['To'] = 'my email';
$headers['Subject'] = 'this is a test';

$params['host'] = 'my smtp outgoing mail host';
$params['port'] = '25';
$params['auth'] = TRUE;
$params['username'] = 'my email';
$params['password'] = 'my password';

$body = 'testing 1 2 3';

$mail = &Mail::factory('smtp', $params);

$mail->send($recipients, $headers, $body);

Here are some other details about my setup that might be useful:

When I type pear config-show
Configuration:
==============
auto_discover <not set>
default_channel pear.php.net
preferred_mirror pear.php.net
remote_config <not set>
PEAR executables directory bin_dir /usr/local/php5/bin
PEAR documentation directory doc_dir /usr/local/php5/lib/php/doc
PHP extension directory ext_dir /usr/local/php5/lib/php/extensions/no-debug-non-zts-20050922
PEAR directory php_dir /usr/local/php5/lib/php
PEAR Installer cache directory cache_dir /tmp/pear/cache
PEAR data directory data_dir /usr/local/php5/lib/php/data
PHP CLI/CGI binary php_bin /usr/local/php5/bin/php
PEAR test directory test_dir /usr/local/php5/lib/php/test
Cache TimeToLive cache_ttl 3600
Preferred Package State preferred_state stable
Unix file mask umask 22
Debug Log Level verbose 1
HTTP Proxy Server Address http_proxy <not set>
PEAR server master_server pear.php.net
PEAR password (for password <not set>
maintainers)
Signature Handling Program sig_bin /usr/local/bin/gpg
Signature Key Directory sig_keydir /usr/local/php5/etc/pearkeys
Signature Key Id sig_keyid <not set>
Package Signature Type sig_type gpg
PEAR username (for username <not set>
maintainers)

I do notice when I look at a page with phpinfo() I don't see anything about PEAR. I wasn't sure if I am supposed to see something about PEAR in there or not. In any case, when I comment out that last line of code with the send function the page loads like it should. Anyone have any thoughts?

Dual G4 Quicksilver 1 GHz Mac OS X (10.4.6)

Posted on May 2, 2006 11:38 AM

Reply
6 replies

May 2, 2006 12:28 PM in response to saf

I use Marc Liyanage's module also on OS X Server 10.3.9 and 10.4.6. I haven't had any problems with it.

You might want to try upgrading the PEAR package(s).
<pre>/usr/local/php5/bin/pear list-upgrades
/usr/local/php5/bin/pear upgrade-all</pre>
See if that resolves any problems.

Otherwise, just try ratcheting up the error reporting temporarily:
<pre>error_reporting( E_ALL );</pre>
and, after your send step...
<pre>if( PEAR::isError( $mail ) {
die( $mail->getMessage() );
}</pre>
to see if that gives you more clues. Otherwise, looks pretty much like what I have in front of me.

May 2, 2006 2:08 PM in response to Wesley Furgiuele

I type the following and this is what I get:

pear list-upgrades

Notice: Undefined index: release_state in Remote.php on line 371
Available Upgrades (stable):
============================
Package Local Remote Size
HTML_Table 1.6.1 (stable) 1.7.0 (stable) 13.7kB
Mail 1.1.9 (stable) 1.1.10 (stable) 16.5kB
PEAR Array () 1.4.9 (stable) 277kB

pear upgrade-all
Will upgrade html_table
Will upgrade mail
Will upgrade pear
downloading HTML_Table-1.7.0.tgz ...
Starting to download HTML_Table-1.7.0.tgz (13,984 bytes)
.....done: 13,984 bytes
No handlers for package.xml version 2.0

What does that mean? Also, when I added the lines:

error_reporting( E_ALL );
if( PEAR::isError( $mail ) ){
die( $mail->getMessage() );
}

I get nothing, but since upgrading to php5 I am not getting any error messages throughout my code. How do I fix this?

Mac OS X (10.4.6)

May 2, 2006 2:28 PM in response to saf

I had a problem also with getting no error messages sometimes, even when setting my error reporting to the highest level. This typically happened when there was a fatal error due to parsing. Haven't really gotten it resolved yet.

As for PEAR, try just upgrading PEAR first:
<pre>sudo /usr/local/php5/bin/pear upgrade --alldeps pear</pre>
(I always have to do this with sudo -- you might not.)

Then see if you can get proper results from pear list-upgrades (no error/notice messages).

May 2, 2006 2:44 PM in response to Wesley Furgiuele

O.K. I typed:

pear upgrade --alldeps pear

and this is what I got:

downloading PEAR-1.4.9.tgz ...
Starting to download PEAR-1.4.9.tgz (283,443 bytes)
..........................................................done: 283,443 bytes
upgrade ok: channel://pear.php.net/PEAR-1.4.9
PEAR: Optional feature webinstaller available (PEAR's web-based installer)
PEAR: Optional feature gtkinstaller available (PEAR's PHP-GTK-based installer)
PEAR: Optional feature gtk2installer available (PEAR's PHP-GTK2-based installer)
To install use "pear install PEAR#featurename"

I wasn't sure if it actually upgraded it or not so I typed:

pear info PEAR

and I get:

Could not get contents of package "/usr/local/php5/bin/pear". Invalid tgz file.

If I type:

pear list-upgrades

I get the same results:

Notice: Undefined index: release_state in Remote.php on line 371
Available Upgrades (stable):
============================
Package Local Remote Size
HTML_Table 1.6.1 (stable) 1.7.0 (stable) 13.7kB
Mail 1.1.9 (stable) 1.1.10 (stable) 16.5kB
PEAR Array () 1.4.9 (stable) 277kB

What does the Array() mean anyways? Moving on, then I typed:

sudo pear upgrade --alldeps Mail

and it upgraded successfully. Now the code is working and I am sending email again! Thank you so much for your help in leading me to the solution (--alldeps). If you find out how to get the error reporting to work again let me know, and I will do the same if I figure it out.

Mac OS X (10.4.6)

May 3, 2006 1:01 PM in response to Wesley Furgiuele

I figuered out how to get parse errors and any other error for that matter to show now. In the php.ini file (/usr/local/php5/lib/php.ini) the following lines under the section "Error handling and logging" were set to:

display_errors = Off
log_errors = On

So the errors were being logged and not displayed, which is probably a good idea for some websites. I went in there and changed them to:

display_errors = On
log_errors = Off

Now all the errors are showing, if anything too many now, heh. Hope that helps.

Mac OS X (10.4.6)

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

anyone using php5 and the PEAR Mail to send smpt mail?

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.