- 1). Decide how you will run your PHP code. If you have a PHP server, you can execute code using PHP files. If you do not have access to a PHP server, you can use an online PHP interpreter. Enter the code in this tutorial into either a PHP file or the online PHP interpreter.
- 2). Begin your PHP program with the following statement:
<?php - 3). Declare a string that will contain the subject of your email. You can name the string something logical, like "emailSubject," and assign it a short message like this:
$emailSubject = 'This is a test email' - 4). Declare a string that will contain the body of the email:
$emailBody = 'This is the body of the test email' - 5). Send the email using the mail function. Pass in the email address you want to send mail to and the two strings declared previously. The finished statement looks like this:
mail('anon@email.com', $emailSubject, $emailBody); - 6). Conclude your PHP program with the statement below. Your program is now ready to be tested on your PHP server or online PHP interpreter.
?>
previous post