Monday, May 13, 2013

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.

No comments:

Post a Comment