Include 3rd party library pear mail

hmm this may sound simple but how do i include 3rd party libs??

for example i wanna include pear mail, where should i place it?? in extension dir or models dir??

It depends,

I would place it in a protected/vendors and then import it… with [font="Menlo, Consolas,"][size="2"][color="#008000"]Yii::import()[/color][/size][/font]

Then you configure it in protected/config to include the directory…

Example…


	// autoloading model and component classes

	'import'=>array(

		'application.models.*',

		'application.components.*',

        'application.vendors.*',

	),

Then you drop your 3rd party library inside it.

or you could follow the recommended directory structure http://www.yiiframew…ect-site/#c3192

Hope that helps ;)

Hi,

tks. i actually place into the extensions dir and tried calling manually like this:


require_once(Yii::app()->basePath.

					'/extensions/PearMail/Mail-1.2.0/Mail.php');

		

		require_once(Yii::app()->basePath.

					'/extensions/PearMail/Mail_Mime-1.8.1/mime.php');

it works for a while but now its giving an error:


include(Mail_smtp.php) [<a href='function.include'>function.include</a>]: failed to open stream: No such file or directory

any idea why now its autoloading??

my function is as follows:


public function sendEmail($toEmail='', $subj='', $body='', 

							  $smtpUsrName='', $smtpPasswd='', $frmHdr='') {

				

		require_once(Yii::app()->basePath.

					'/extensions/PearMail/Mail-1.2.0/Mail.php');

		

		require_once(Yii::app()->basePath.

					'/extensions/PearMail/Mail_Mime-1.8.1/mime.php');

		

		$body = nl2br($body);

       

	    $headers = array(

	    'From' => $frmHdr,

	    'To' => $toEmail,

	    'Subject' => $subj);

	    

	    $smtp = Mail::factory('smtp',

	     array ('host' => $this->smtpHost,

	       'auth' => true,

	       'username' => $smtpUsrName,

	       'password' => $smtpPasswd));

	

	    //Mime settings

	    $crlf = "\n";

	    $mime = new Mail_mime($crlf);

	    $mime->setHTMLBody($body);

	

	    //do not ever try to call these lines in reverse order

	    $htmlbody = $mime->get();

	    $headers = $mime->headers($headers);

	    

	    $mail = $smtp->send($toEmail, $headers, $htmlbody);

	

	    if (PEAR::isError($mail)) {

	      	return false;

	    }

	    else {

	     	return true;

	    }

	}	

sorry my bad. it was some directory issue. weird cos my file got removed after i rename the directory. am using eclipse =)

Glad to know its working out