• vijayj

    (@vijayj)


    I am using a contact form in my website and I need to sent the details to a particular email in the same server as email.

    My hosting provider shared the below code ,but I don’t know how and where to use this.
    Please help.

    <?

    $mailto=”[email protected]”;
    $pcount=0;
    $gcount=0;
    $subject = “Mail from Enquiry Form”;

    $from=”[email protected]”;
    while (list($key,$val)=each($_POST))
    {
    $pstr = $pstr.”$key : $val \n “;
    ++$pcount;

    }
    while (list($key,$val)=each($_GET))
    {
    $gstr = $gstr.”$key : $val \n “;
    ++$gcount;

    }
    if ($pcount > $gcount)
    {
    $message_body=$pstr;
    mail($mailto,$subject,$message_body,”From:”.$from);
    echo “Mail has been sent”;
    }
    else
    {
    $message_body=$gstr;
    mail($mailto,$subject,$message_body,”From:”.$from);
    echo “Mail has been sent”;
    }
    ?>

Viewing 5 replies - 1 through 5 (of 5 total)
  • Jarret

    (@jarretc)

    Are you using a plugin for the contact form? Most of them allow to you specify where the form details get submitted to. You can just set it to whatever email address you want even if it is on the same domain.

    Thread Starter vijayj

    (@vijayj)

    I am using Contact form 7 plugin

    Jarret

    (@jarretc)

    Ok, easy enough then. Go to your dashboard, then Contact->Contact Forms. Hover over the form you want to modify, click on the Edit link below the name. Then click on the Mail tab and set the To field input to whatever email address you want the form to send the information to.

    Thread Starter vijayj

    (@vijayj)

    So only the contact form plugin is needed .

    Then I add the SMTP settings and the above php script

    Jarret

    (@jarretc)

    You may need to configure SMTP settings yes, but you don’t need the above script. Contact Form 7 handles the form/email part for you.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Senting email with php’ is closed to new replies.