Results 1 to 2 of 2

Thread: After a form submission have email auto sent

  1. #1
    Join Date
    May 2005
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default After a form submission have email auto sent

    I'm not sure if this is the right section for this question.
    I have a simple contact form on my site. I want to have a pre-made email be auto sent out to the user right after they submit the form. Maybe this could be done through php, or through the form submission? If anyone knows of a way to do this is php, html or anything please reply.

    Thank you!

  2. #2
    Join Date
    Sep 2005
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by immersion08
    I'm not sure if this is the right section for this question.
    I have a simple contact form on my site. I want to have a pre-made email be auto sent out to the user right after they submit the form. Maybe this could be done through php, or through the form submission? If anyone knows of a way to do this is php, html or anything please reply.

    Thank you!
    Code:
    <?php
    $to = $_POST['email'];
    $from = ""; //the email address you want it from (the address does not have to exist to work)
    $headers = "From: $from";
    $subject = "Autoreply";
    $message = "Replace this with your custom email message";
    $mailsent = mail($to, $subject, $message, $headers);
    
    if ($mailsent) {
    echo "<p>Yay! The following data has been sent:<br /><br />";
    echo "<strong>By: </strong> " . $from . "<br />";
    echo "<strong>About:</strong> " . $subject . "<br />";
    echo "<strong>Comments:</strong>
    " . $message . "<br />";
    echo "</p>";
    }
    else {
    echo "There was an error sending this data. Please retry";
    }
    ?>
    That will send a mail to the user on submit. Use this form to send it:
    Code:
    <form action="script.php" method="post">
    <label for="email">Your email</label><br />
    <input name="email" id="email" />
    <input type="submit" value="send me a mail" />
    </form>

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •