Welcome to my website. My name is Jamie Balfour and I am a computer scientist and a teacher. My website focuses on me but I also write articles and reviews on and related to technology as well as tutorials designed to help you learn things I know.
As this tutorial has no doubt shown, PHP is a powerful programming language with many powerful functions. What has still to be covered in this tutorial emphasises this further.
PHP includes a set of functions that permit sending email messages using the web server that the PHP interpreter is run from.
PHP provides a very simple function called
The function takes three essential parameters which themselves become hearders for the email:
<?php mail($to, $subject, $message); ?>
All of these parameters are self-explanatory.
<?php mail($to, $subject, $message, $headers); ?>
$headers variable is a string variable that specifies more headers for the email. The following table
shows some of these headers and their purpose:
|From||The email address that the email came from|
|Content-Type|| What type of content the email contains. For instance
|X-Priority||The priority level of the email. This specifies how high the email should be in terms of priority in the recipient's email inbox. Use with caution.|
|Reply-To||The address that should receive any replies.|
|Cc||Carbon-copy (CC). Send a 'carbon-copy' of the email to a recipient.|
|Bcc||Blind-carbon-copy (BCC). Send a 'carbon-copy' of the email blindly to a recipient.|
|Mime-Version||Specifies the Multipurpose Internet Mail Extension (MIME) version used with the email.|
Headers should be separated with the carriage return character (in UNIX it is
PHP can send HTML-based emails rather than the standard text based emails using the
<?php $content = "<strong>Hello world</strong>"; $headers = "MIME-Version: 1.0\rContent-Type: text/html; charset=utf-8\r" mail($to, $subject, $message, $headers); ?>
Retweet@MetroUK: 'My black lab ran off last night... look who I find him with.'😂🐐 https://t.co/ds4ymTxnn2
6 hours ago
Sad about @andy_murray but still exceptionally proud of his achievements! Loved every moment (some were extremely i… https://t.co/zvsmM4u9IJ
11 days ago
I don't even have the slightest bit of trust for this man. https://t.co/z0FYRms3GR
19 days ago
19 days ago