PHP form mail problems
-
Hi, again, everyone.
I got WordPress working OK on our website.
With one exception…I’m trying to get a feedback form on our website to work. Here’s the .PHP code:
<?php // require_once "Mail.php"; $from = "[email protected]"; $userfrom = Trim(stripslashes($_POST['email'])); $to = "[email protected]"; $subject = "Website Feedback"; $fname = $_POST['firstname']; $lname = $_POST['lastname']; $address = $_POST['address']; $city = $_POST['city']; $state = $_POST['state']; $postcode = $_POST['zipcode']; $tel = $_POST['telephone']; $fax = $_POST['fax']; $message = $_POST['message']; $host = "mailhub.registeredsite.com"; $username = "[email protected]"; $password = "ELIDED"; // validation $validationOK=true; if (Trim($userfrom)=="") $validationOK=false; if (!$validationOK) { print "<meta http-equiv=\"refresh\" content=\"0;URL=index.php\">"; exit; } // prepare email body text $Body = ""; $Body .= "First Name: "; $Body .= $fname; $Body .= "\n"; $Body .= "Last Name: "; $Body .= $lname; $Body .= "\n"; $Body .= "Address: "; $Body .= $address; $Body .= "\n"; $Body .= "City: "; $Body .= $city; $Body .= "\n"; $Body .= "State: "; $Body .= $state; $Body .= "\n"; $Body .= "ZIP Code: "; $Body .= $zipcode; $Body .= "\n"; $Body .= "Telephone: "; $Body .= $tel; $Body .= "\n"; $Body .= "Fax: "; $Body .= $fax; $Body .= "\n"; $Body .= "Email: "; $Body .= $userfrom; $Body .= "\n"; $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("" . $mail->getMessage() . " "); } else { echo("Message successfully sent! "); } ?>
Of course, the password has been changed…
The ‘[email protected]’ is what Interland (web.com) said to put for the From: line, and the mail server is what they said to use.
Here’s the error I’m getting:
Warning: main(Mail.php) [function.main]: failed to create stream: No such file or directory in d:\Customers\user1234567\www\cgi-bin\contact.php on line 2 Fatal error: main() [function.main]: Failed opening required 'Mail.php' (include_path='.;c:\php4\pear') in d:\Customers\user1234567\www\cgi-bin\contact.php on line 2
Here’s what Interland support said (although it’s not very helpful to me, I’m afraid):
Please check and modify your scripts because these are the values you should be using:
Directive Local Value Master Value
sendmail_from [email protected] [email protected] sendmail_path no_value no_value
SMTP mailhub.registeredsite.com
smtp_port 25Anyone have any ideas how to get this working?
Thanks.
- The topic ‘PHP form mail problems’ is closed to new replies.