PHP makes sending information to an email rather easy. It takes one main command :
The first value is an email address. Where the information is going to be sent to.
The second value is a short sentense or note. It will appear in the SUBJECT field of the email.
The third value is the main body message.
Values can be entered directly into the mail command.
Many people prefer to use variables to pass the information into it.
To know if the email was successfully sent out, an IF command can be used on the mail command. The mail command produces a positive result upon success.
The further email tutorial pages will build onto this example. Change the values to your own, save it it as a php file, upload and test it on your hosted space. Viewing the page, the script will automatically go and send an email. If it works, you are ready to continue further.
mail ("recipient","subject","message");
The first value is an email address. Where the information is going to be sent to.
The second value is a short sentense or note. It will appear in the SUBJECT field of the email.
The third value is the main body message.
Values can be entered directly into the mail command.
<?php
mail("yourplace@somewhere.com","My email test.","Hello, how are you?");
?>
mail("yourplace@somewhere.com","My email test.","Hello, how are you?");
?>
Many people prefer to use variables to pass the information into it.
<?php
$to = "yourplace@somewhere.com";
$subject = "My email test.";
$message = "Hello, how are you?";
mail($to,$subject,$message);
?>
$to = "yourplace@somewhere.com";
$subject = "My email test.";
$message = "Hello, how are you?";
mail($to,$subject,$message);
?>
To know if the email was successfully sent out, an IF command can be used on the mail command. The mail command produces a positive result upon success.
<?php
$to = "yourplace@somewhere.com";
$subject = "My email test.";
$message = "Hello, how are you?";
if ( mail($to,$subject,$message) ) {
echo "The email has been sent!";
} else {
echo "The email has failed!";
}
?>
$to = "yourplace@somewhere.com";
$subject = "My email test.";
$message = "Hello, how are you?";
if ( mail($to,$subject,$message) ) {
echo "The email has been sent!";
} else {
echo "The email has failed!";
}
?>
The further email tutorial pages will build onto this example. Change the values to your own, save it it as a php file, upload and test it on your hosted space. Viewing the page, the script will automatically go and send an email. If it works, you are ready to continue further.

