 |
|
|
| View previous topic :: View next topic |
| Author |
Message |
linson
Joined: 19 Nov 2009 Posts: 1 Location: cochin
|
Posted: Thu Nov 19, 2009 1:21 pm Post subject: cannot send php mail script with SMTP Authentication |
|
|
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 <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>");
}
?>
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 |
|
 |
davis
Joined: 07 Jan 2010 Posts: 5 Location: Toronto
|
Posted: Fri Jan 08, 2010 12:47 am Post subject: |
|
|
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 |
|
 |
|
|
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
|
|