自动向给定的电子邮件ID发送确认消息

I have a form which has a field for email id. When form is submitted then a confirmation message should be send automatically to the given email id, how?

I want to do this in php.

<?php mail($email, 'thanks for your comment', 'many thanks, we will get back to you'); ?>

To send the messages use this code ,

  <?php
  //define the receiver of the email
  $to = 'youraddress@example.com';
  //define the subject of the email
  $subject = 'Test email';
  //define the message to be sent. Each line should be separated with 

  $message = "Hello World!

This is my first mail.";
  //define the headers we want passed. Note that they are separated with 

  $headers = "From: webmaster@example.com
Reply-To: webmaster@example.com";
  //send the email
 $mail_sent = @mail( $to, $subject, $message, $headers );
 //if the message is sent successfully print "Mail sent". Otherwise print "Mail failed" 
 echo $mail_sent ? "Mail sent" : "Mail failed";

?>

and for the activation code , use your database , create a table with email and number auto_increment and when he register in the database , in database will create the auto code and that code send to email ,