norNerd Posted November 25, 2009 Share Posted November 25, 2009 Hi people, I have to use smtp connection insted of the regular mail(); function..Runned over a script wich uses the pear mail package included in php 4 or later. Here is the script: <?phprequire_once "Mail.php"; //This one is my problem, i dont have a file anywhere wich is named Mail.php, should i just create one? :s$from = "Sandra Sender <sender@example.com>";$to = "Ramona Recipient <recipient@example.com>";$subject = "Hi!";$body = "Hi,\n\nHow are you?";$host = "mail.example.com";$username = "smtp_username";$password = "smtp_password";$headers = array ('From' => $from, 'To' => $to, 'Subject' => $subject);$smtp = Mail::factory('smtp', array ('host' => $host, 'auth' => true, 'username' => $username, 'password' => $password));$mail = $smtp->send($to, $headers, $body);if (PEAR::isError($mail)) { echo("<p>" . $mail->getMessage() . "</p>"); } else { echo("<p>Message successfully sent!</p>"); }?> Got this code from:http://email.about.com/od/emailprogramming...hentication.htmRemoved require_once "Mail.php";And got fatal error, class Mail not found, so guess the file Mail.php have something to do with the missing function? :sKris Link to comment Share on other sites More sharing options...
justsomeguy Posted November 25, 2009 Share Posted November 25, 2009 Yeah, the Pear Mail class is defined in that file. If you have Pear installed correctly then it will set the PHP include path to look for those files in the correct location. Link to comment Share on other sites More sharing options...
norNerd Posted November 25, 2009 Author Share Posted November 25, 2009 So i have to download the pear package(Mail.php) and put require_once "Mail.php"; into my send mail script again ? :)Kris Link to comment Share on other sites More sharing options...
justsomeguy Posted November 25, 2009 Share Posted November 25, 2009 You want to install all of Pear, the Mail package might depend on other packages. Once you install it all of the include files will be in the Pear directory and it will modify the PHP include path so that PHP always checks in that directory if it can't find the include file in another place. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.