PEAR Forum :: PHP Extension and Application Repository

PEAR Forum Forum Index
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
cannot send php mail script with SMTP Authentication

 
Post new topic   Reply to topic    PEAR Forum Forum Index -> Mail
View previous topic :: View next topic  
Author Message
linson



Joined: 19 Nov 2009
Posts: 1
Location: cochin

PostPosted: Thu Nov 19, 2009 1:21 pm    Post subject: cannot send php mail script with SMTP Authentication Reply with quote

Hello,

I'm getting following error while try to send mail via php script with smtp authentication

Mail Sent.
Fatal error: Undefined class name 'mail' in test.php line 16

script is for eg :

<?php
require_once "Mail.php";

$from = "Sandra Sender <[email protected]>";
$to = "Ramona Recipient <[email protected]>";
$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>");
}
?>

I'm not able to send mail with above script.I have php 5 installed on my machine.Does i need install pear on my machine.There is a file go-pear.bat in the php5 directory.Also include path specified in php.ini is
include_path = ".;./includes;./pear"
There is only one file under pear directory which is "go-pear.phar"

In script there is mail.php specified - > require_once "Mail.php.what is that meant for ? shall i need to create mail.php file ? what should be the entries inside it ?

I think pear is not installed on my machine.Could you please help me to send mail with SMTP authentication

Please advise.
Back to top
View user's profile Send private message Send e-mail Yahoo Messenger
davis



Joined: 07 Jan 2010
Posts: 5
Location: Toronto

PostPosted: Fri Jan 08, 2010 12:47 am    Post subject: Reply with quote

It really looks like PEAR isn't installed properly on your machine.

What you should see in the directory where PEAR is installed is a file called 'Mail.php' and a 'mail' dir. In the dir there will be another 'mail.php' (note all lowercase), and other PEAR things like 'mime.php' and 'Queue.php' etc.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    PEAR Forum Forum Index -> Mail All times are GMT + 2 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum



PEAR Forum topic RSS feed 
Powered by phpBB © 2001, 2005 phpBB Group

Provided by Ministry of Web developement