Skip to content


Solving the include_once error in Pear Mail

I have this hosting from hosting.india.to and helping on a friend’s community development initiative by setting up his website. It may soon move to careforindia.org.

During that, I set up a email form on my system, using PHP’s PEAR mail package to send mail. Though it worked fine on my own system, it didn’t on the hosting server. And no errors either.

First enabled the Error messages by putting this is the first line of the php file.

ini_set('display_errors','1'); ini_set('display_startup_errors','1'); error_reporting (E_ALL);

And then out popped the error.

Warning: Mail_smtp::include_once(Net/SMTP.php) [mail-smtp.include-once]: failed to open stream: No such file or directory in /home/username/php/Mail/smtp.php on line 206


Warning: Mail_smtp::include_once()[function.include]: Failed opening 'Net/SMTP.php' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/username/php/Mail/smtp.php on line 206


Fatal error: Class 'Net_SMTP' not found in /home/username/php/Mail/smtp.php on line 210

Apparently the basedir is set incorrectly and since I need to ask the hosting person to change the configuration, and to avoid the hassle, the simplest solution was to edit line 206 in /home/username/php/Mail/smtp.php to have

include_once '/home/username/php/Net/SMTP.php';

include_once 'Net/SMTP.php';

Yes, that is the full path.

Once I did that, I also got an error from Net/SMTP.php with it finding difficulty in locating Socket.php.

Same solution again and everything looks hunky dory. Clean up the error reporting and any debugging steps in between.

Oh, by the way, the site is at careforindia.jsemmanuel.com/donate.php and will soon be moved to www.careforindia.org

Posted in Troubleshooting.

Tagged with , , , .


0 Responses

Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.



Some HTML is OK

or, reply to this post via trackback.