PHPJavascript

Web Development Guide – My Personal Library of Tutorials and Scripts

Send emails with PHP mail() function

April15

To send email using php scripts we use a simple function mail() in the following way:

$to= “anyemail@hotmail.com”; //to address
$headers =”From: your@hotmail.com \n”; //from address
$headers .= “MIME-Version: 1.0 \n”;
$headers .= “Content-type: text/html; charset=iso-8859-1 \n”;
$subject =”Good Morning”;

$body=”Have a good day and enjoy sending emails”;

mail($to,$subject,$body,$headers)

where $to, $subject, $body, $headers are variables

Note: You can connect this to a form as well. Use $_POST to retrieve the variables and use them in mail()

This function might not work on your local computer (as SMTP server not present) so upload the file on the web and then test.

posted under PHP

Email will not be published

Website example

Your Comment:

 

3,055 spam comments
blocked by
Akismet