Menu

Form Gen - email help (not same as others)

Help
Rich B
2009-11-08
2013-06-03
  • Rich B

    Rich B - 2009-11-08

    *emphasized text*emphasized textI have set up a form using the generator.

    Everything works except it won't email.

    I checked with my host and they advise the following………..

    What needs to be included is;

    1. A variable that tells the script where the email is being sent from; For example; $SendEmail ="enquire@domainname.com";
    2. Adding this variable onto the end of the mail() function. Below is a very basic php script, I have included the extra entries in italic.

    $nameField = $_POST;
    $emailField = $_POST;
    $SendEmail ="enquiry@domainname.com";
    $body = <<< EOD

    Name: $nameField
    Email: $emailField
    EOD;

    $headers = "From: $emailField\r\n";
    $headers .= "Content-type: text/html\r\n";
    $sucess = mail($webMaster, $emailSubject, $headers, $body, '-f'.$SendEmail);

    The important part here is the '-f'.$SendEmail at the end of the mail() function. The '-f' although not a php command is a sendmail parameter that is telling our mailserver the mail is being sent from the $SendEmail address and nowhere else.

    My processor.php is as follows……..

    <?php

    /* $where_form_is="http://".$_SERVER.strrev(strstr(strrev($_SERVER),"/")); */

    session_start();
    if( ($_SESSION==$_POST) && (!empty($_POST)) ) {
    mail ="info@mydomaingoeshere.com","Customer Enquiry Form","Form data:

    Title: " . $_POST . "
    First Name: " . $_POST . "
    Second Name: " . $_POST . "
    Email Address: " . $_POST . "
    How did you get to our website?: " . $_POST . "
    Enquiry: " . $_POST . "

    powered by phpFormGenerator.
    " );

    include("confirm.html");
    }
    else {
    echo "Blah Blah Blah.";
    }

    ?>

    Can someone please advise where I should put the bits my hosts advises, as I have tried loads and my php skills are low.

    Many Thanks in Advance.

    Rich

     
  • Rich B

    Rich B - 2009-11-09

    Solution found elsewhere (Experts Exchange).

    I think you can get away with simply specifying the sendmail_from by using the following on a Windows machine:

    ini_set ("sendmail_from","webmaster@MyWebSite.com");

    This needs to be put at the top of script, just under <?php

     
  • Aaron Hardy

    Aaron Hardy - 2009-11-15

    Can you show a preview of  yours…?

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.