0

Possible Duplicate:
Need to Send Email from HTML pages

Is there a way to use a form to send an email with no database? Is there an html element that can do this?

Community
  • 1
  • 1
lampShade
  • 4,361
  • 8
  • 34
  • 50
  • you said no DB, do you also mean no Server Side code as well? – Doon Jul 24 '12 at 01:25
  • You need an e-mail service to send e-mails. There's most likely an API available for that. But it'd be using others' service then - such as sending the data over ajax for another server to send the e-mail. – Fabrício Matté Jul 24 '12 at 01:28
  • 1
    No you can't..without any server side program in any server side language like PHP, java, ASP, you cannot send mail.. And also a Yes, because you don't need any database for sending mail. – Asif Jul 24 '12 at 01:30

4 Answers4

3

You could use an email link:

<a href="mailto:person@domain.tld">Person</a>

Edit: If you really want to use a form, you could take advantage of the mailto parameters such as subject, body, cc, and bcc to customize your email. Here is an example:

// JS 
// Uses jQuery but could be done without
$(function() {
    $('div').click(function() {
        var emailLink = $('#email');
        emailLink.attr('href', 'mailto:person@domain.com?subject=' + $('#subject').val() + '&body=' + $('#body').val());
    })
});
/* CSS */
div {
    cursor: pointer;
    color: blue;
    text-decoration: underline;
}
<!-- HTML -->

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
Subject: <input type="text" id="subject"><br>
Body: <input type="text" id="body"><br>

<div>Update Email Settings</div>
<a id="email" href="mailto:person@domain.com">
    Send Email
</a>

Note that this would still use the user's default email client and will not send the email on its own. However, it allows you to change the subject and content of the email from your form and pass it to the email client.

Julian E.
  • 4,687
  • 6
  • 32
  • 49
Zhihao
  • 14,758
  • 2
  • 26
  • 36
  • I'm familiar with that method thank you. I want to use a form because it looks more professional. – lampShade Jul 24 '12 at 01:27
  • 2
    @lampShade: as I user I prefer `mailto:` solution better. Not sure why you think the form looks more professional, but with my email client I at least know that message has been send (and archived so I could find it if needed) – zerkms Jul 24 '12 at 01:32
  • 1
    The way it looks is just CSS. The second solution uses form (`input`) elements too, just not wrapped in a `form`. HTML is flexible. There is no other (pure JS+HTML) solution other than to open an external email client. Any reasonable solution for doing this purely over the web involves server code. – Tony R Jul 24 '12 at 02:25
2
<a href="mailto:name@company.com">someOne</a>

It will open a Email Client software, like MS-Outlook. If you want to send it directly with HTML & JS, it's impossible.

Cos, the mail need SMTP-protocol to send the mail, but the browser only support HTTP-protocol. you need a SMTP server to send mail and also with some server side code,like php or jsp...

meadlai
  • 895
  • 1
  • 9
  • 22
1

If you mean you want to send the email dynamically, will need more than HTML and JavaScript like PHP or ASP.net.

syanaputra
  • 590
  • 1
  • 5
  • 12
1

You can use a hyperlink to make user to click on then redirect user to the default mailing system. For example, you can use

<a href="mailto:user@gmail.com">Username</a>
Joanne
  • 1,226
  • 13
  • 15