Reputation: 673
I have a form in one of my html files and I want to form to submit the email directly to the email specified in the MAILTO attribute of the form.
<form role="form" action="mailto:[email protected]" method="get" enctype="text/plain">
<div class="form-group">
<label for="emailinput"><h4><span class="glyphicon glyphicon-envelope"></span> E-mail</h4></label>
<input class="form-control" type="email" id="emailinput" placeholder="Entrez votre e-mail">
</input>
</div>
<div class="form-group">
<label for="messageinput"><h4><span class="glyphicon glyphicon-pencil"></span> Message</h4></label>
<textarea class="form-control" id="messageinput" placeholder="Ecrivez votre message" rows="3"></textarea>
</div>
<br/>
<div class="text-right">
<button type="submit" class="btn btn-default">
<span class="glyphicon glyphicon-upload"></span> Envoyer
</button>
</div>
</form>
When I test and click on it,I have a windows live mail window that opens instead of sending the email to the right address.
What do I need to do to make it send the email? (info: my back end is implemented in Java)
Upvotes: 0
Views: 1947
Reputation: 34321
The mailto
URI scheme typically causes a browser to open an new email in the default mail application. It's basically a shortcut to avoid having to re-type the email address and optionally the subject and body.
This is all explained in the mailto Wikipedia article:
The mailto URI scheme, as registered with the Internet Assigned Numbers Authority (IANA), defines the scheme for Simple Mail Transfer Protocol (SMTP) email addresses. It allows users clicking a link in a website to send an e-mail without first having to copy the destination e-mail address and open an e-mail client. Though its use is not strictly defined, URLs of this form are intended to be used to open the new message window of the user's email client when the URL is activated, with the address as defined by the URL in the "To:" field.
If you want to use a webpage to allow the composition of an email, which is then sent when you click the submit button, then you'll need to write a servlet (or simlar) that receives the form input and then uses JavaMail to send the actual email using SMTP.
Upvotes: 1
Reputation: 9479
Yes normally we need mail framework like JavaMail to send emails. I think you are trying some other new feature through html.
From this link http://www.html5-tutorials.org/forms/sending-the-data/ it says "... functionality depends on the email-client installed on your users’ computer."
Upvotes: 1
Reputation: 26
You cannot use the mailto as your form action. Your form action must go to back-end code (e.g.: servlet).
Change your form as follows:
<form role="form" action="/SendEmail" method="get" enctype="text/plain">
<div class="form-group">
<label for="emailinput"><h4><span class="glyphicon glyphicon-envelope"></span> E-mail</h4></label>
<input class="form-control" type="email" id="emailinput" placeholder="Entrez votre e-mail">
</input>
</div>
<div class="form-group">
<label for="messageinput"><h4><span class="glyphicon glyphicon-pencil"></span> Message</h4></label>
<textarea class="form-control" id="messageinput" placeholder="Ecrivez votre message" rows="3"></textarea>
</div>
<br/>
<div class="text-right">
<button type="submit" class="btn btn-default">
<span class="glyphicon glyphicon-upload"></span> Envoyer
</button>
</div>
</form>
For the sample of servlet code. Please refer to this link http://www.tutorialspoint.com/servlets/servlets-sending-email.htm
Thanks
Upvotes: 1
Reputation: 777
You cannot send an email using that code, client side. You need to send the data to the server and from there if you use java you can use JavaMail: http://www.oracle.com/technetwork/java/javamail/index.html
Upvotes: 1
Reputation: 5342
I'm no expert, but without an e-mail (SMTP) server you can not send e-mail. If you do not have an SMTP server, there might be some way to do it through things like Gmail, you'll have to Google that.
Upvotes: 1
Reputation: 39477
To send an email, you need SMTP server.
You cannot send it from a web page directly.
Upvotes: 1