Problem with form submit.

Links for php scripts

Moderators: macek, egami, gesf

New php-forum User
New php-forum User
Posts: 1
Joined: Sun Jun 24, 2012 10:20 pm

Problem with form submit.

Postby nateleduc » Sun Jun 24, 2012 10:39 pm

I'm new to php and writing a php script to let me know that someone is trying to contact me. Unfortunately I don't know what the problem is. Here is my current code:

require_once "contact-form-handler2.php";

$from = "xxxx Sender <>";
$to = " Recipient <>";
$subject = "Hi!";
$body = "Hi,\n\nHow are you?";

$host = "tls//";
$port = "587";
$username = "";
$password = "xxxx";

$headers = array ('From' => $from,
'To' => $to,
'Subject' => $subject);
$smtp = Mail::factory('smtp',
array ('host' => $host,
'port' => $port,
'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 keep getting the error :

( ! ) Fatal error: Class 'Mail' not found in C:\Users\Nathan\Desktop\Website\Website\mail.php on line 17
Call Stack
# Time Memory Function Location
1 0.0004 678920 {main}( ) ..\mail.php:0

line 17 is " $smtp = Mail::factory('smtp'," I know it has something to to with the variable "Mail," but I can't quite get it running.

Currently, I'm working on my site locally, using Apache (WAMP), but once I get my site finished I will be a hosting company, which will also host my email client, then I will change it from hotmail/live

User avatar
php-forum Active User
php-forum Active User
Posts: 335
Joined: Tue Feb 22, 2011 8:19 am
Location: Canada

Re: Problem with form submit.

Postby freshnet » Tue Jun 26, 2012 9:49 am

is it as simple as using capitalized 'Mail' instead of 'mail'?

Return to “PHP Scripts”

Who is online

Users browsing this forum: No registered users and 1 guest