Techno World Inc - The Best Technical Encyclopedia Online!

THE TECHNO CLUB [ TECHNOWORLDINC.COM ] => PHP => Topic started by: Hellraiser on August 29, 2007, 10:15:46 AM



Title: Send emails with PHP mail() function
Post by: Hellraiser on August 29, 2007, 10:15:46 AM
Send emails with PHP mail() function

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

$to=  "[email protected]";  //to address
$headers ="From: [email protected]"; //from address
$headers .= "MIME-Version: 1.0n";
$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.