How to Send Email from a PHP Script using mail() function
Posted by Raj
How to Send Email from a PHP Script using mail() function.
In this article, I will show you how to send mail using PHP mail() function in PHP.
PHP mail() function:
The PHP mail() function is used to send emails in php.Syntax :
mail(string to, string subject, string message, string headers,parameters);
to: The receiver of the email
subject: The subject of the email.
message: the body of the email.
headers: Additional headers, like From, Cc, and Bcc.
Example:
<?php
$to = "rajesh@example.com";//The receiver of the email
$subject = "Test mail"; //The subject of the email.
$body = "Hello!"; //The body of the email.
$from = "test@example.com";
$headers = "From:" . $from;
//mail() function
if(mail($to,$subject,$message,$headers))
{
echo("Message successfully sent!");
}
else
{
echo("Message delivery failed...");
}
?>
This entry was posted on October 4, 2009 at 12:14 pm, and is filed under
how do i send mail,
how to send email,
how to send emails,
mail send,
mail(),
PHP,
php email,
PHP interview questions and answers,
send mail,
smtp
.You can leave a response, or trackback from your own site.