mail( ) function in PHP


Email can be send using PHP by using mail( ) function.
Syntax of mail function is

mail (to,subject,message,headers)

Parameter usage
to reciever email
subject Subject of Email
message Content to be sent in message
headers Optional. It is used for additional headers, like From, Cc, and Bcc.

 Now let write the code for sending email.
<?php

 $subject = "Email";
 $message = "This is Test email ";
 $to = "test@gmail.com";
 $from = "aa@gmail.com";
 $headers = "From:" . $from;
 mail($to,$subject,$message,$headers);

?>

No comments:

Post a Comment