• 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 25

    Anyone have any ideas how to get this working?

    Thanks.

Viewing 6 replies - 1 through 6 (of 6 total)
  • Thread Starter graintrader

    (@graintrader)

    I might add that the $_POST values are all properly set up in a .php file on our Contact page.

    Does Mail.php exist? And does it have a capital letter ‘M’? It’s telling you that it can’t find the file.

    Thread Starter graintrader

    (@graintrader)

    That’s the problem… I have no idea. The file this code is in is called contact.php.

    You’ll notice that I have the second line in the code above commented out… so it shouldn’t be looking for that file… but it does that whether or not I’ve got that line commented out.

    Does the “c:\php4\pear” give me any clue as to how to fix this? I’m afraid I don’t even know what’s going wrong with this, so I have no idea how to fix it.

    Thread Starter graintrader

    (@graintrader)

    And, I don’t know why it keeps adding “cgi-bin” in that path… I didn’t reference anything in the cgi-bin directory. Is that where mail.php is supposed to go?

    Thread Starter graintrader

    (@graintrader)

    Ok, rather than trying to get this working, I’m going to just enable moderated comments. The comments will have to be emailed to me prior to being posted on the website, so I’ll see them, read them, and delete them.

    Thread Starter graintrader

    (@graintrader)

    Well, I couldn’t get the comments thing to work properly… when someone posts a comment, it gets displayed on the web page, even before it’s gone to the moderator for approval!

    So, I installed the Dagon Design form mail script plugin for WordPress, and it’s all working great. Even has Turing image verification…

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘PHP form mail problems’ is closed to new replies.