Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Old 10-03-2008, 05:20 AM php mail problem
Junior Talker

Posts: 1
Trades: 0
Hello,

i have a php mail script with smtp authontication:
php Code:

<?php

$from = "DEFTEC <info@deftec.gr>";

$to = "rallystas13@hotmail.com>";

$subject = "Hi!";

$body = "Hi,\n\nHow are you?";



$host = "89.234.63.108";

$username = "info@deftec.gr";

$password = "7791dima";



$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>");

}

?>

the error message is this:
Quote:
Fatal error: Undefined class name 'mail' in C:\inetpub\vhosts\deftec.gr\httpdocs\mail.php on line 14

line 14 is this $smtp = mail::factory('smtp',

Thanks

http://www.infysolutions.com

Outsourcing software development
charlie123 is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 10-03-2008, 09:21 AM Re: php mail problem
rogem002's Avatar
PHP Chap

Posts: 843
Name: Mike
Location: United Kingdom
Trades: 0
PHP Code:
<?php

$from 
"DEFTEC <********@****.***>";// removed this email

$to "********@****.***>"// removed this email

$subject "Hi!";

$body "Hi,\n\nHow are you?";



$host "********"// Removed the host name

$username "*********"// hidden

$password "*******"// hidden



$headers = array ('From' => $from,

'To' => $to,

'Subject' => $subject);

$smtp mail::factory('smtp'); // this is the line at fault added a ) and a ;

array ('host' => $host,
'auth' => true,
'username' => $username,
'password' => $password); // took out the extra bracket



$mail $smtp->send($to$headers$body);



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

echo(
"<p>" $mail->getMessage() . "</p>");

} else {

echo(
"<p>Message successfully sent!</p>");

}

?>
Looks to me like you have forgotten to include the PEAR file or you have just got fulgy code. I adjusted as needed.
__________________
My Blog/Site:
Please login or register to view this content. Registration is FREE

Last edited by rogem002; 10-03-2008 at 09:23 AM..
rogem002 is offline
Reply With Quote
View Public Profile Visit rogem002's homepage!
 
Old 10-03-2008, 09:23 AM Re: php mail problem
maxxximus's Avatar
Extreme Talker

Posts: 219
Name: Rob
Location: UK
Trades: 0
Your script needs PEAR's mail class. http://pear.php.net/package/Mail

Most hosts will have this installed already.

Just put this at the top of your script.

PHP Code:
require_once('Mail.php'); 
maxxximus is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to php mail problem
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.17442 seconds with 12 queries