The following code/tutorial explains about sending email using php mail() function. The thing you must understand is :
to – the person whom you are sending the message
subject – What is the subject of your email
message – This portion contains the overall message to be sent to the receiver
header - Header is the additional information like the sender email address
Syntax
mail(to, subject,message,header);
This function returns the boolean value ‘True’ if the mail is sent successfully, otherwise it returns ‘False’.
Sample PHP Code
<?php
//Check whether the submission is made
if(isset($_POST[‘submit’])){
//Declarate the necessary variables
$to=$txtEmailto;
$from=$txtEmailfrm;
$subject=$txtSub;
$mail_mesg=$txtMsg;
//Check for success/failure of delivery
if(mail($to,$subject,$mail_mesg,”From:$from/r/nReply-to:$from”))
echo ‘successfully send’;
else
echo ‘Sorry, error occured while sending your email’;
}
?>