0

I am developing a static website just for informative purpose. What I need is functionality that would let any webiste visitor request additional information by email (info@edugru.com). My domain name is www.edugru.com.

I am not using any database. It's just a static website. So how can I add this email functionality by javascript in my app?

naktinis
  • 3,957
  • 3
  • 36
  • 52
nitin verma
  • 616
  • 1
  • 6
  • 22

2 Answers2

2

Try this:

<p>
This is an email link:
<a href="mailto:info@edugru.com" target="_top">Send Mail</a>
</p>
Amy
  • 4,034
  • 1
  • 20
  • 34
  • thanks for your answer but I want to add mail subject and body which enter by user. – nitin verma May 05 '16 at 11:25
  • @nitinverma you can remove subject if you don't want. User will later add it manually..See updated answer – Amy May 05 '16 at 11:27
  • actually I have four textbox userName, phoneNo, emailid massage . now I want when user click on send button. these all detail will send on company mail address – nitin verma May 05 '16 at 11:32
2

You have (at least) two choices :

  1. Client side only, no server side scripts.

You can add something like this in the page:

<a href="mailto:info@edugru.com?subject=Some subject&body=The message body&cc=other_address@edugru.com">Send email</a>

Se a lot of useful other examples here: Can I set subject/content of email with using mailto:?

Clicking on the above link would open a new window of the default email client (if any) installed on the client machine. You will get a Thunderbird or Outlook or whatever email client is the default. The To, Subject, Body, CC, etc.. will be filled with the values you provided in the HTML code above. This is the maximum you can do in this approach. The message will NOT be sent automatically. A human action would be necessary to hit Send button on the email client window. This requires the client machine to have a email client properly configured.

  1. Using a server side script.

The only way to automatically send the message is to submit the data to a server side script (running either on your edugru.com or somewhere else) that would connect further (in a form or another) to a mail server and send the data. You can't achieve this using HTML and JavaScript only.

[Edited to detail the server side approaches..]

See two options below for sending the email from a server side script. I'm assuming you have PHP available on the server.

a. Use PHP mail function. See usage examples here: http://php.net/manual/en/function.mail.php

b. Use PHPMailer class for more complex options: http://phpmailer.worxware.com/?pg=tutorial

Community
  • 1
  • 1
Ciprian Stoica
  • 2,309
  • 5
  • 22
  • 36