Anonymous
Anonymous asked in Computers & InternetProgramming & Design · 1 decade ago

Send a Form via Email? PHP?

Earlier this year I found a neat tutorial that allowed me to send forms on my webpage to my email, without any knowledge of PHP on my part. I created a form on my site with labels for each field. I was then able to create a text file as a template for my email, complete with variable labels. All I had to do was link the text file to the form via a hidden field and then have the form action go to this .php file.

I have since lost the link to this tutorial, and I cannot find it despite 4 hours of searching. Are there any other methods to do this?

2 Answers

Relevance
  • Anonymous
    1 decade ago

    Here's an example script; the e-mail should send properly. I have an issue with it where it sends to the junk box however.

    <?php

    $_src = $_POST['sender'];

    $_sName = $_POST['sndrName'];

    $_rName = $_POST['rcpName'];

    $_dst = $_POST['recip'];

    $_subj = $_POST['subj'];

    $_body = $_POST['body'];

    $_head = "From: " . $_sName . " <" . $_src . ">\n" .

    "To: " . $_rName . " <" . $_dst . ">\n" .

    "Reply-To" . $_src . "\n" .

    "X-Mailer: PHP/" . phpversion() .

    "MIME-Version: 1.0\r\n" .

    "Content-type: text/html; charset=iso-8859-1\n";

    if (mail($_dst, $_subj, $_body, $_head)) {

    echo "We get signal<i>!!</i>";

    } else {

    echo "You fail it! Your skill is not enough!";

    }

    ?>

    I had to rewrite the code recently; so I don't know what I did last time that made it work properly, whereby the emails were sent to the inbox as opposed to the junk folder.

  • 1 decade ago

    We have to use this method: mail(to,subject,message,headers,parameters);

    If you are using in local system you have to take care about the smtp installations.

    and you have to set the smtp post number as 25.

    Even you have problem you have to chedk your code once again.

    If its the server first you find where exactly SMTP server .

    Then you have to give the SMTP server path.

    I hope you are clear about this query.

Still have questions? Get your answers by asking now.