Solved

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

Posted on 2011-03-10
5
193 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
  • 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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

CSS is a visual language used to classify objects and define rules about how they should be displayed. CSS skills aren’t restricted to developers anymore, there is a big benefit to having a basic understanding of the language, regardless of your occ…
Why do we like using grid based layouts in website design? Let's look at the live examples of websites and compare them to grid based WordPress themes.
In this Micro Tutorial viewers will learn how to create a CSS image sprite (In a later tutorial, viewers will learn how to use CSS and HTML to create a navigation menu using this sprite) Open a new Photoshop document with a width of (Icon width)x(N…
In this tutorial viewers will learn how to style rounded corners for elements in CSS using the border-radius property Begin with a normal styled element such as a div: To style all four corners of the div to be the same degree of roundness, use the …

747 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now