Organizational Research By

Surprising Reserch Topic

How to Send Email from a PHP Script using mail() function using php?



asked Sep 13, 2013 in PHP by ashish singh
edited Sep 12, 2013
0 votes
15 views



Related Hot Questions

1 Answer

0 votes
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:
 
 
$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...");
}
?> 
answered Sep 13, 2013 by ashish singh
edited Sep 12, 2013

...