将文本框中的输入发布到电子邮件?

将文本框中的输入发布到电子邮件?

问题描述:

I'm trying to build a simple sign up form where a person enters their email and submits.

This input is then emailed to the owner of the site, I thought the code below would work however it isnt?

<form id="signup-form" method="post" action="mailto:email@server.co.uk">
    <input type="text" name="email" id="email" placeholder="Email Address">
    <input type="submit" value="Sign Up">
</form>

You have only created the HTML file. HTML file never interacts with server. To send mail either you have to use Javascript of PHP.

PHP Code to send email:

    <?php
   $to      = 'nobody@example.com';
   $subject = 'the subject';
   $message = 'hello';
   $headers = 'From: webmaster@example.com' . "
" .
   'Reply-To: webmaster@example.com' . "
" .
     'X-Mailer: PHP/' . phpversion();

   mail($to, $subject, $message, $headers);
    ?>

Documentaion

Send Email Using Javascript