Mail()

Creator:
Virst

To send an email in PHP is very simple. Just use the mail() function. Here is an example:



<?php 
         mail
('to@whom.com''subject of the email'"the email's message!""headers"); 
?>

The only required parameters are the first 3 (to, subject, and message). The headers are what can make HTML enabled, and show who the email is from. Here is an example:


<?php 
// HEADERS: 
    
$headers "From: from@whom.com"
    
$headers "Content-type: text/html"
    
// To 
    
$to "colby@virst.net"
    
// Subject 
    
$subject "A test"
    
$message "<html><head> <title>An email</title> </head> <body> 
    <b>HELLO!</b> This is a <u>really</u> cool email! </body> </html>"

    
mail($to$subject$message$headers); 
?>

When the person gets the email it will look like this: HELLO! This is a really cool email!

Description:
Learn how to send mail in PHP!

Comments

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

More information about formatting options