Search code examples
phpemailpear

PHP Pear Mail - Include Path


I am working on a PHP project that uses PHP's built in mail function. I am adding the option to use Pear mail.

It seems that in most hosting environments, using:

require_once('Mail.php') 

doesn't work which is what all of the examples I could find show. Writing the include path as:

require_once('/path/to/pear/Mail.php')

also doesn't seem to work. However, setting the include path like:

set_include_path('/path/to/pear/')
require_once('Mail.php')

does work. Because there is a configuration file in my app where this is stored and the config is used in most of my pages (not having to do with email), I am not sure if this is a good idea. My config file now has the values stored like this:

// pear smtp mail settings
set_include_path('/path/to/pear/');
define('PEAR_INCLUDE_PATH', 'Mail.php');
define('SMTP_HOST', 'ssl://smtp.gmail.com');
define('SMTP_PORT', '465');
define('SMTP_USER', '[email protected]');
define('SMTP_PASS', 'password');

Is this going to create problems for me? How should I do this?

Thank you


Solution

  • Your pear include path should be set globally in your php.ini file -- if not, you have a broken pear/php installation.

    But if you want to be extra-paranoid, you could ship a local copy of pear's Mail and Net_SMTP modules.