Question:

How can I create an html form data sent to my email.

by  |  earlier

0 LIKES UnLike

Hello, I'm a novice web designer and I have problem. How can I create an html for that when data is submitted the data will be sent to my email address? For instance a mailing list where all they need to do is type in there email address and when they hit send their email address (the data they entered) will be sent to my email address where I can read it. Does anyone know the code for it? Thank you!

 Tags:

   Report

1 ANSWERS


  1. There's a lot of ways to do it, you should search 'php email' on google.

    But here's the basics:

    $eol = "\r\n";

    $random_hash = md5(date('r', time()));

    $to = "mailingTo@yahoo.ca";

    $subject = "This is your email's topic";

    $header = "mailingFrom@yahoo.ca";

    $header = $header . $eol . "Content-Type: multipart/alternative; boundary=\"PHP-alt-".$random_hash."\"";

    $the_body = "Whatever you are mailing. Maybe use php code, create a For loop here, and append all the email addresses into this variable, or something.";

    ob_start();

    ?>

    --PHP-alt-<?php echo $random_hash; ?>  

    Content-Type: text/plain; charset="iso-8859-1"

    Content-Transfer-Encoding: 7bit

    <?php echo $the_body; ?>

    Body continues; if HTML is disabled on your account.

    --PHP-alt-<?php echo $random_hash; ?>  

    Content-Type: text/html; charset="iso-8859-1"

    Content-Transfer-Encoding: 7bit

    <?php echo $the_body; ?>

    <br/><br/><hr><br/>

    Body continues; If HTML runs on your account.

    --PHP-alt-<?php echo $random_hash; ?>--

    <?php

    $message = ob_get_clean();

    if (mail($to,$subject,$message,$header)) { //Tries to send Email. Returns with an error if it fails.

    $mailSent = true;

    } else {

    $mailSent = false;

    }

    echo "Zero means it failed, One means it worked: " . $mailSent;

Question Stats

Latest activity: earlier.
This question has 1 answers.

BECOME A GUIDE

Share your knowledge and help people by answering questions.