-2

I know that there are multiple posts and questions out there on How to send an email from HTML form. But, I am having a slightly different query.

I have an HTML form, what I want is that when I click on submit, it should not show the information in a mail, but it should directly send the form information to recipients email ID. When I tried the following code:

<form action="mailto:dummy1@chamisplace.com" method="POST" 
enctype="multipart/form-data"
      name="EmailTestForm">

Your Name:<br>
<input type="text" size="20" name="VisitorName"><br><br>

Your Comment:<br>
<textarea name="VisitorComment" rows="4" cols="20">
</textarea><br><br>

<input type="submit" value="Email This Form">

</form>

It is opening a MS Outlook window with the form information. But it is not sending it automatically.

Cœur
  • 37,241
  • 25
  • 195
  • 267
V15HM4Y
  • 1,757
  • 4
  • 26
  • 40
  • 1
    You can't directly send an email from a form like that. The most you can do is put a `mailto:` URL, look [here](http://stackoverflow.com/questions/6792855/syntax-for-mailto) and [here](http://en.wikipedia.org/wiki/Mailto) for more information. Edit: you can probably use some Javascript that will generate a `mailto` link based on the contents of a form. –  Feb 03 '14 at 09:39
  • 2
    You've tagged this `php`, did you look at http://php.net/mail ? – Quentin Feb 03 '14 at 09:40
  • mailto open any associated mail program either use php mail or use mailto like this mailto:dummy1@chamisplace.com?subject=abc&body=xyz – Maz I Feb 03 '14 at 09:41
  • You can't send it automatically because it opens a foreign application which you can't control with html/PHP – Class Feb 03 '14 at 09:49

3 Answers3

1

use mail() function of php

mail($email_to, $email_subject, $email_body)

and you have to configure ur email

http://stackoverflow.com/a/18185233/2535521
Saurabh Kachhia
  • 300
  • 3
  • 12
0
<?php

$to="mailaddredd";
$from= "ownmailaddress";
$subject="Subject";
$message ="Comments";

mail($to,$subject,$message);

 ?>
Vikas Gautam
  • 997
  • 7
  • 23
0

If you are using only mailto for your action and not using any PHP script you can't send it automatically because you are having your form open and send data to the users prefered email program which can't be controlled remotely as far as sending emails. That is a good thing because that would be a way to spam people without thinking/knowing about it.

If you are looking to use PHP to send an email there's tons of libraries and tutorials on this site or even searching Google.

Class
  • 3,149
  • 3
  • 22
  • 31