Looking for somewhere to host your site? Browse our PHP web hosts section!

Home > Code Snippets > Send email using the PHP mail() function

Send email using the PHP mail() function

Description

How to send an email from within a PHP page using the built in mail() function.

The code


<?php


// Your email address
$email "you@example.com";

// The subject
$subject "Enter your subject here";

// The message
$message "Enter your message here";

mail($email$subject$message"From: $email");

echo 
"The email has been sent.";

?>

Get the code

Download the file to your computer: Click here to get the file