E-mail With PHP.
PHP uses its inbuilt mail() function to send emails from the script.
Syntax:mail(to,subject,message,headers,parameters)
Example:<?php
$to = "sample@ sample.com";
$subject = " sample mail";
$message = “sample email message.";
$from = " sample1@ sample.com";
$headers = "From: $from";
mail($to,$subject,$message,$headers);
echo "Mail Sent.";
?>
Header is an optional parameter that specifies any CC or BCC. The mail function requires a working email system. SMTP settings needs to be done in the .ini file.
E-mail With PHP.
PHP supports sending email through a form. First enter the to address, from address, subject, message fields from a simple html form. In the html file use the tag with action attribute assigned with the php file, which handles sending email.
Example:<form method="post" action="mailContact.php">
Ensure that proper validation is done for mail form.
The script should take the data posted from the form- to mail id, from mail id, subject, message etc into corresponding variables, using $_REQUEST.
Use the function mail() as follows to send the mail to the destination address.
mail($to, $subject, $body, $headers);