Solved

How can i sent a comment directly to the email address?

Posted on 2011-03-10
5
198 Views
Last Modified: 2012-05-11
Dear Experts,

Here is what I want on my website. I have a simple form (textarea) and a submit button on my page.
And whenever a comment is submitted I want that comment to go to my email address xyz@gmail.com.
How can I do that ?

Thank you inadvance
<form method="post" action="support.html" >
  Send your comments to our email address:<br />
  <textarea name="comments" id="comments">
  
  </textarea><br />
  <input type="submit" value="Submit" />

</form>

Open in new window

0
Comment
Question by:kate2001
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
5 Comments
 
LVL 15

Expert Comment

by:Jagadishwor Dulal
ID: 35106210
You will need a serverside script like php, asp or any other which can post your comment to direct in email like below I am showing you an example of php.
<?php
if(isset($_POST['submit'])){
$to = "xyz@gmail.com";
$subject = "Comment";
$comment = $_POST['comments'];
$headers = "From: comment@webpage.com" ;

mail($to,$subject,$comment,$headers);
?>

Open in new window

0
 
LVL 82

Accepted Solution

by:
leakim971 earned 500 total points
ID: 35113570
Using the PHP code of jagadishdulal and jQuery (readability and simplicity) :

(the comments is submitted silently with Ajax)

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script language="javascript" src="http://code.jquery.com/jquery-1.5.min.js"></script>
<script language="javascript">
	$(document).ready(function() {
		$("form").submit(function(e) {
			e.preventDefault();
			$.post("jagadishdulal.php", $("form").serializeArray(), function() {
				alert("Thanks for your comments!!!");
			});
		});
	});
</script>
</head>
<body>
<form id="myform" method="post" action="support.html" >
Send your comments to our email address:<br />
<textarea name="comments" id="comments"></textarea><br />
<input type="submit" value="Submit" />
</form>
</body>
</html>

Open in new window

0
 

Author Comment

by:kate2001
ID: 35121409
jagadishdulal and leakim971,

Thank you so much for the help.

I have used your approach but it seems like the comment is not being send out to my email.

What am I missing here?
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script language="javascript" src="http://code.jquery.com/jquery-1.5.min.js"></script>
<script language="javascript">
        $(document).ready(function() {
                $("form").submit(function(e) {
                        e.preventDefault();
                        $.post("sendsend.php", $("form").serializeArray(), function() {
                                alert("Thanks for your comments!!!");
                        });
                });
        });
</script>
</head>
<body>
<form id="form" method="post" action="support.html" >
Send your comments to our email address:<br />
<textarea name="comments" id="comments"></textarea><br />
<input type="submit" value="Submit" />
</form>
</body>
</html>

Open in new window

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>
<?php
if(isset($_POST['submit'])){
$to = "xyz@gmail.com";
$subject = "Comment";
$comment = $_POST['comments'];
$headers = "From: comment@webpage.com" ;

mail($to,$subject,$comment,$headers);
?>
</body>
</html>

Open in new window

0
 
LVL 82

Expert Comment

by:leakim971
ID: 35123435
You may found some answers here for example, section Setting extension-specific variables: http://www.techrepublic.com/article/a-tour-of-the-phpini-configuration-file-part-2/5272345
0
 
LVL 82

Expert Comment

by:leakim971
ID: 35380100
Thanks for the points!
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Building a website can seem like a daunting task to the uninitiated but it really only requires knowledge of two basic languages: HTML and CSS.
When crafting your “Why Us” page, there are a plethora of pitfalls to avoid. Follow these five tips, and you’ll be well on your way to creating an effective page.
In this tutorial viewers will learn how to code links for mobile sites that, once clicked, send a call or text to a specified number. For a telephone link (once clicked, calls a number), begin with a normal "<a href=" link tag. For the href, specify…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question