Reputation: 113
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.
Upvotes: 0
Views: 1220
Reputation: 71
To send the messages use this code ,
<?php
//define the receiver of the email
$to = '[email protected]';
//define the subject of the email
$subject = 'Test email';
//define the message to be sent. Each line should be separated with \n
$message = "Hello World!\n\nThis is my first mail.";
//define the headers we want passed. Note that they are separated with \r\n
$headers = "From: [email protected]\r\nReply-To: [email protected]";
//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 ,
Upvotes: 0
Reputation: 31068
<?php mail($email, 'thanks for your comment', 'many thanks, we will get back to you'); ?>
Upvotes: 1