I have an HTML form; can I send an email with the contents of the form when the user clicks the submit button, using only HTML?
How do I have the email sent with a certain subject?
I have an HTML form; can I send an email with the contents of the form when the user clicks the submit button, using only HTML?
How do I have the email sent with a certain subject?
HTML is run on the client side. You need a server if you want to send an email. Something like node or php. Once you have a server running and hosting your html, you can lookup the documentation to send an email.
Here's an example of a php server sending an email: How to send an email using PHP?
you need php or server side language to make this work.......e.g.
HTML FILE:
<form action="answer.php" method="POST">
email address: <input type="text" "name="email"/>
Name: <input type="text" name="name"/>
<input type="submit"/>
</form>
Php file answer.php
<?php
//form validation
if( $_POST ) {
$name=$_POST['name'];
$email=$_POST['email'];
$subj= "my subject or do a form field!";
$content = "content from a form field etc!";
$to= "myemail@email.com";
$from = "from: $email";
}
if ( $email ) {
mail($to, $subj, $content, $from);
}
?>
To be honest you are opening up a whole new chapter on your skills. the above code will be much abused by spammers, etc. You might be better to look at wordpress which you can use to provide a lot of the php code you need through plugins etc. You can use a outlook open but again this opens your email to spammers, etc.
if you are using php you can use phpmailer phpmailer
Very easy to use and it has great documentation
You can also use "MAILTO:someone@example.com" as your form action.
<form action="MAILTO:someone@example.com" method="post" enctype="text/plain">
Name:<br>
<input type="text" name="name" value="your name"><br>
E-mail:<br>
<input type="text" name="mail" value="your email"><br>
Comment:<br>
<input type="text" name="comment" value="your comment" size="50"><br><br>
<input type="submit" value="Send">
<input type="reset" value="Reset">
</form>
Without using PHP, your only option is to set up your fields and let the user complete the email from their Email client (ie. Outlook). See this link for the code: http://www.w3schools.com/html/tryit.asp?filename=tryhtml_form_mail.