Sending a mail from your script
By admin | December 13, 2007
Many a times you want to send a mail to someone through your website you can easily do that by the php inbuilt function mail
Syntax:
mail(to,subject,message,headers,parameters);
To: == The person email you are sending the mail to
Subject: == The subject of the email
Message: == The main email message can consist of the new line character ( \n ) tab character ( \t ) etc
Parameters: == Optional parameters
Creating the script to send a mail:
<?php
$to = “someone@someone.com”;
$subject = “Checking Mail Function”;
$message = “This is the body of the email.”;
$from = “something@something.com”;
$headers = “From: $from”;
mail($to,$subject,$message,$headers);
echo “Mail Sent.”;
?>
Now this script every time when it will run it will send a mail to the email someone@someone.com
You can add user input to it by using if , isset functions
Hint: isset is a function which checks that a form field is filled or not used in db functions also
Thanks
krates
Topics: PHP | Comments Off on Sending a mail from your script
Related Links: