Send email with PHP

Posted by Shek on April 19, 2008 under PHP | Be the First to Comment | Total View: 212 views

In this post, I would like to show you how to send an email with PHP code. It is very useful for a member system which you might like to email the password to member.


To be able to send email, PHP has a function called mail( ).

To send a simple email, mail( ) function takes 3 parameters.

First one is the “destination address“, I use a PHP variable $to to store it in this example.
Second one is the subject line of the email, I use a PHP variable $subjectline to store it in this example.
Third one is the content of the email, I use a PHP variable $content to store it in this example.

Here are the codes within the PHP file:

<?php
//create a destination address
$to = "xxxxxxxxxxx@phpsuperblog.com";
//create a subject line
$subjectline = "test email";
//create the content
$content = "How are you";
//Now use the mail() function to send the email
mail ($to, $subjectline, $content);
?>

Run this PHP file, and then the email will be sent to the destination address.

Similar Posts:

VN:F [1.9.13_1145]
Rating: 0.0/10 (0 votes cast)
VN:F [1.9.13_1145]
Rating: 0 (from 0 votes)

Add A Comment

*